• Uncategorized

About linux : Compile-from-o-Files-to-dll-File-in-Linux

Question Detail

Im trying to compile/link .o file(s) into a .dll file under Ubuntu…

i get it nearly to work but i have a problem with static linking these .o file(s) …

Here is what ive done:

First i installed all dependencies … then i build the following application:

https://github.com/Zeranoe/mingw-w64-build

On my Ubuntu.

After that i create the .o files from the application with normal “sudo make” command…

Now i had all .o file(s) ready … then i modified the .o files with “dlltool” so now i have the opportunity to link them to a .dll file with “mingw” … it works only in “shared mode” … not in “static mode” …

this is the working command:

sudo /home/robert/Downloads/mingw-32/x86_64/i686/bin/i686-w64-mingw32-g++ -shared -lmsvcrt -Wl,-subsystem,windows *.o -o phpcppdll.dll

and this is not working:

sudo /home/robert/Downloads/mingw-32/x86_64/i686/bin/i686-w64-mingw32-g++ -static -lmsvcrt -Wl,-subsystem,windows *.o -o phpcppdll.dll

and then i get the following error – with this command:

/home/robert/Downloads/mingw-32/x86_64/i686/bin/../lib/gcc/i686-w64-mingw32/11.2.1/../../../../i686-w64-mingw32/bin/ld: /home/robert/Downloads/mingw-32/x86_64/i686/bin/../lib/gcc/i686-w64-mingw32/11.2.1/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a(lib32_libmingw32_a-crt0_c.o):crt0_c.c:(.text+0x3c): undefined reference to `WinMain@16'
collect2: error: ld returned 1 exit status

but i dont get further maybe you have an idea …

Question Answer

Okay – i got it to work with the -nostartfiles flag … but it dont make sense because all .dlls are not static … but shared …

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.