This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Issues with LD when using GCC in a C program


Philip Herron <herron.philip@googlemail.com> writes:

> 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...

Note that popen, unlike execl, runs the shell, which leads to various
security issues.  execl is definitely to be preferred when there is any
user control over arguments or the environment.  That may not be an
issue in this particular case, of course.

Ian



> 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
>>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]