mingw-cross-env-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Mingw-cross-env-list] Link Errors


From: Nagaev Boris
Subject: Re: [Mingw-cross-env-list] Link Errors
Date: Fri, 31 Jul 2015 22:52:10 +0300

On Fri, Jul 31, 2015 at 10:52 AM, Thomas Dineen <address@hidden> wrote:
> Gentle People:
>
>     I am getting the following link errors on these fairly trivial programs.
> Please note the the code compiles and links perfectly on Solaris with gcc
> with no linking command line options.
>
>    Am I missing a -l library command line option?
>
>    I will post the source on request.
>
>    In what libraries are the symbols sprintf_s and address@hidden found?
> So exactly what do I add to the command line?
>
>     These errors seem quite strange to me in that usually google will tell
> you
> what library the symbol is in and then you just add -llib to the command
> line?
>
>    Please help I have spent hours on google have ended up exhausted and
> confused!
> Written at 12:51 AM!
>
> i686-pc-mingw32-gcc Test_Shared.c dlfcn.c -lpsapi -o Test_Shared.exe
>
> /tmp/ccJEa2nO.o:dlfcn.c:(.text+0x2fb): undefined reference to `sprintf_s'
> and address@hidden
> collect2: error: ld returned 1 exit status

win32 mingw/gcc doesn't have sprintf_s

Make sure you have main() or WinMain() defined. Please show your code.


> i686-pc-mingw32-gcc dlfcn.c -lpsapi -o dlfcn.o
>
> /tmp/cc6fCJ7Q.o:dlfcn.c:(.text+0x2fb): undefined reference to `sprintf_s'
> /home/tdineen/Mxe_Cross_Environment_120213/mxe/usr/lib/gcc/i686-pc-mingw32/4.8.1/../../../../i686-pc-mingw32/lib/libmingw32.a(main.o):main.c:(.text.startup+0xa7):
> undefined reference to address@hidden'
> collect2: error: ld returned 1 exit status
> Linux3%

It tries to link instead of just compile.
Try flag -c


>
> i686-pc-mingw32-gcc Test_Lib.c -o Test_Lib.so
>
> /home/tdineen/Mxe_Cross_Environment_120213/mxe/usr/lib/gcc/i686-pc-mingw32/4.8.1/../../../../i686-pc-mingw32/lib/libmingw32.a(main.o):main.c:(.text.startup+0xa7):
> undefined reference to address@hidden'
> collect2: error: ld returned 1 exit status
>
>

Add -shared and -fPIC




-- 


Best regards,
Boris Nagaev



reply via email to

[Prev in Thread] Current Thread [Next in Thread]