ID:1628631
 
I've created a .so library to use in BYOND but I keep getting runtime errors.

The Log:
Running UNIX
runtime error: Unable to load library plugins/cryptobyond.so
proc name: SHA1 (/proc/SHA1)
usr: null
src: null
call stack:
SHA1("55627")
: OpenPort(55627)


I've created a windows .dll version and it works flawlessly.

Both are created in Release Mode and not Debug using the crypto++ library.

I've installed it on linux via "sudo apt-get install" and such.

Is there some APIENTRY DllMain() I don't know about for linux?


//Linux: extern "C" const char
//Windows: extern "C" __declspec(dllexport) const char


Do I still use __declspec() or no?
Is it possible that your library is being compiled as 64-bit? BYOND is a 32-bit program so it most likely will have trouble loading that. You can use the -m32 option to g++ to force 32-bit compatability, if this is the problem.
The -m32 solution did not work.
what is the output of 'file [yourfile].so' ? It should be 32-bit ELF to work properly.
my output of the file is only this::

//Output file is bin/Release/libBYONDCRYPT.so with size 113.35 KB


for the full compiler details:

/*
-------------- Build: Release in BYONDCRYPT (compiler: GNU GCC Compiler)---------------

g++ -Wall -fexceptions -O2 -Wall -m32 -c /home/dale/Desktop/projects/BYONDCRYPT/main.cpp -o obj/Release/main.o
g++ -shared obj/Release/main.o -o bin/Release/libBYONDCRYPT.so -s -m32
Output file is bin/Release/libBYONDCRYPT.so with size 113.35 KB
Process terminated with status 0 (0 minute(s), 2 second(s))
0 error(s), 0 warning(s) (0 minute(s), 2 second(s))
*/
Hmm, that's odd that it not giving you more details. how about 'objdump -a libBYONDCRYPT.so'?

I suspect you need to install the 32-bit dev tools so you can build this properly. Let me dig that info up (pretty sure someone posted it in the Linux forum as well). But first we should see what your library format is.
/*
dale@dale-Satellite-A305:~/Desktop/projects/BYONDCRYPT/bin/Release$ objdump -a libBYONDCRYPT.so

libBYONDCRYPT.so: file format elf32-i386
libBYONDCRYPT.so
*/
Hmm, so the format is fine (are you on a 32-bit machine)? I'm thinking the problem is that you are putting it in a subdir that isn't in the LD_LIBRARY_PATH. What happens when you put the lib in the same dir as DreamDaemon?
I am on a 32-bit machine and I'll check what happens right now
The error still occurs.
So to be clear, you have the libBYONDcrypt.so in the same dir with libbyond.so etc?
correct, they are in "/usr/local/byond/bin/"
why don't you upload the file and I can try it on a linux box here.
I got the one I named "cryptobyond.so" in there as well as "libBYONDCRYPT.so" in there as well.
also a snippet of code to test it.
Alright, will do.
well it should be named whatever you access it from within your file. So I would expect you to have call("libBYONDCRYTP.so",...")
well I did rename it to cryptobyond.dll after creating it. So I have it do this:

call("plugins/cryptobyond.so","SHA256")("HASHME")
Oh, I think the problem is that you have that "plugins" there. If the library is in your BYOND bin folder, it shouldn't have an additional path. Alternatively, you can add the plugins/ dir to your LD_LIBRARY_PATH (but just to be sane, I'd test the following:
call("cryptobyond.so","SHA256")("HASHME")
with the library in your BYOND bin.