This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Issues with LD when using GCC in a C program
- From: Philip Herron <herron dot philip at googlemail dot com>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: eugaia at gmail dot com, gcc-help at gcc dot gnu dot org
- Date: Mon, 30 Mar 2009 10:27:38 +0100
- Subject: Re: Issues with LD when using GCC in a C program
- References: <49C86555.6000106@gmail.com> <m3fxh3dmyx.fsf@google.com>
Hey
Instead of using execl you could also use: popen
http://linux.die.net/man/3/popen
Brings you back the outputs like stdout stderr etc...
-Phil
2009/3/24 Ian Lance Taylor <iant@google.com>:
> Marcus Clyne <eugaia@gmail.com> writes:
>
>> // compile the shared object
>>
>> execl ("/usr/bin/gcc",
>> ? ? ? ? ? "-shared",
>> ? ? ? ? ? "-lmylib",
>> ? ? ? ? ? "-o",
>> ? ? ? ? ? so_file,
>> ? ? ? ? ? object_file,
>> ? ? ? ? ? NULL);
>
> Note that -lmylib is in the wrong place. ?Libraries must follow the
> objects which refer to them.
>
> It does not make sense that you would get an undefined symbol error when
> using -shared, so I don't know what is going on. ?It is unlikely that
> you are missing anything from the environment.
>
> I recommend adding the -v option to your execl, to verify that the
> expected options are being passed to the subprocesses. ?Compare to the
> output using -v on the command line.
>
> Ian
>