Home » Language IDEs » C / C++ IDE (CDT) » project dependency and linking
project dependency and linking [message #137242] |
Wed, 02 February 2005 13:38  |
Eclipse User |
|
|
|
Originally posted by: john.wang.gmail.com
Hi:
I have two C++ projects under CDT. One is a static library, e.g.
testLib which contains a class A.
The other is an .exe project, e.g. testCPP, which has a dependency
on testLib.
My problem is that testCPP cannot link correctly to testLib, e.g.
it cannot resolve A. I've added A.h to the include path of testCPP but
it still could not resolve the objects.
I've set the project reference on testCPP to testLib.
My library is at:
C:\jwang\workspace\testLib\Debug\libtestLib.a
When I set the link path and link library switches, I get the
following
errors:
make -k all
Building target: testcpp.exe
g++ -L"C:\jwang\workspace\testLib\Debug" -o testcpp.exe
test.o -l"C:\jwang\workspace\testLib\Debug\libtestLib.a"
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/../../../../i686-pc-cy gwin/bin/ld:
cannot find -lC:\jwang\workspace\testLib\Debug\libtestLib.a
collect2: ld returned 1 exit status
make: *** [testcpp.exe] Error 1
make: Target `all' not remade because of errors.
Build complete for project testcpp
Any help is greatly appreciated.
Thanks
|
|
|
Re: project dependency and linking [message #137291 is a reply to message #137242] |
Wed, 02 February 2005 16:59   |
Eclipse User |
|
|
|
Hi John,
This will be easy to resolve. First, you have specified the path to your
library correctly, and this is passed to the linker using the -L flag.
The problem is that the linker expects you to specify a library without
the 'lib' prefix and '.a' suffix, so in the library list, just enter
'testLib' (without the single quotes). The linker argument will then be
g++ -L"C:\jwang\workspace\testLib\Debug" -o testcpp.exe test.o
-l"testLib"
and the linker will stop complaining. Hope this helps, and thanks for
posting this on the newsgroup.
Sean
John Wang wrote:
> Hi:
>
> I have two C++ projects under CDT. One is a static library, e.g.
> testLib which contains a class A.
>
> The other is an .exe project, e.g. testCPP, which has a dependency
> on testLib.
>
> My problem is that testCPP cannot link correctly to testLib, e.g.
> it cannot resolve A. I've added A.h to the include path of testCPP but
> it still could not resolve the objects.
>
> I've set the project reference on testCPP to testLib.
>
> My library is at:
> C:\jwang\workspace\testLib\Debug\libtestLib.a
>
> When I set the link path and link library switches, I get the
> following errors:
>
> make -k all
>
> Building target: testcpp.exe
>
> g++ -L"C:\jwang\workspace\testLib\Debug" -o testcpp.exe test.o
> -l"C:\jwang\workspace\testLib\Debug\libtestLib.a"
>
> /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/../../../../i686-pc-cy gwin/bin/ld:
> cannot find -lC:\jwang\workspace\testLib\Debug\libtestLib.a
>
> collect2: ld returned 1 exit status
>
> make: *** [testcpp.exe] Error 1
>
> make: Target `all' not remade because of errors.
>
> Build complete for project testcpp
>
>
>
> Any help is greatly appreciated.
>
>
>
> Thanks
>
|
|
|
Re: project dependency and linking [message #137302 is a reply to message #137291] |
Wed, 02 February 2005 19:12   |
Eclipse User |
|
|
|
Originally posted by: john.wang.gmail.com
Thanks Sean!
This worked!
When I tried to debug my program, I can an "Internal error: Launching"
error dialog. I tried with both the cygwin debugger and the gdb debugger,
with same error.
Any ideas?
Thanks
-John
Sean Evoy wrote:
> Hi John,
> This will be easy to resolve. First, you have specified the path to your
> library correctly, and this is passed to the linker using the -L flag.
> The problem is that the linker expects you to specify a library without
> the 'lib' prefix and '.a' suffix, so in the library list, just enter
> 'testLib' (without the single quotes). The linker argument will then be
> g++ -L"C:jwangworkspacetestLibDebug" -o testcpp.exe test.o
> -l"testLib"
> and the linker will stop complaining. Hope this helps, and thanks for
> posting this on the newsgroup.
> Sean
> John Wang wrote:
>> Hi:
>>
>> I have two C++ projects under CDT. One is a static library, e.g.
>> testLib which contains a class A.
>>
>> The other is an .exe project, e.g. testCPP, which has a dependency
>> on testLib.
>>
>> My problem is that testCPP cannot link correctly to testLib, e.g.
>> it cannot resolve A. I've added A.h to the include path of testCPP but
>> it still could not resolve the objects.
>>
>> I've set the project reference on testCPP to testLib.
>>
>> My library is at:
>> C:jwangworkspacetestLibDebuglibtestLib.a
>>
>> When I set the link path and link library switches, I get the
>> following errors:
>>
>> make -k all
>>
>> Building target: testcpp.exe
>>
>> g++ -L"C:jwangworkspacetestLibDebug" -o testcpp.exe test.o
>> -l"C:jwangworkspacetestLibDebuglibtestLib.a"
>>
>> /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/../../../../i686-pc-cy gwin/bin/ld:
>> cannot find -lC:jwangworkspacetestLibDebuglibtestLib.a
>>
>> collect2: ld returned 1 exit status
>>
>> make: *** [testcpp.exe] Error 1
>>
>> make: Target `all' not remade because of errors.
>>
>> Build complete for project testcpp
>>
>>
>>
>> Any help is greatly appreciated.
>>
>>
>>
>> Thanks
>>
|
|
|
Re: project dependency and linking [message #137431 is a reply to message #137302] |
Thu, 03 February 2005 09:08   |
Eclipse User |
|
|
|
John,
It sounds like an environment problem. Is GDB on the path?
Sean
John Wang wrote:
> Thanks Sean!
> This worked!
>
> When I tried to debug my program, I can an "Internal error: Launching"
> error dialog. I tried with both the cygwin debugger and the gdb
> debugger, with same error.
> Any ideas?
>
> Thanks
>
> -John
>
> Sean Evoy wrote:
>
>> Hi John,
>> This will be easy to resolve. First, you have specified the path to
>> your library correctly, and this is passed to the linker using the -L
>> flag. The problem is that the linker expects you to specify a library
>> without the 'lib' prefix and '.a' suffix, so in the library list, just
>> enter 'testLib' (without the single quotes). The linker argument will
>> then be
>
>
>> g++ -L"C:jwangworkspacetestLibDebug" -o testcpp.exe test.o
>> -l"testLib"
>
>
>> and the linker will stop complaining. Hope this helps, and thanks for
>> posting this on the newsgroup.
>
>
>> Sean
>
>
>> John Wang wrote:
>>
>>> Hi:
>>>
>>> I have two C++ projects under CDT. One is a static library, e.g.
>>> testLib which contains a class A.
>>>
>>> The other is an .exe project, e.g. testCPP, which has a dependency
>>> on testLib.
>>>
>>> My problem is that testCPP cannot link correctly to testLib, e.g.
>>> it cannot resolve A. I've added A.h to the include path of testCPP but
>>> it still could not resolve the objects.
>>>
>>> I've set the project reference on testCPP to testLib.
>>>
>>> My library is at:
>>> C:jwangworkspacetestLibDebuglibtestLib.a
>>>
>>> When I set the link path and link library switches, I get the
>>> following errors:
>>>
>>> make -k all
>>>
>>> Building target: testcpp.exe
>>>
>>> g++ -L"C:jwangworkspacetestLibDebug" -o testcpp.exe test.o
>>> -l"C:jwangworkspacetestLibDebuglibtestLib.a"
>>>
>>> /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/../../../../i686-pc-cy gwin/bin/ld:
>>> cannot find -lC:jwangworkspacetestLibDebuglibtestLib.a
>>>
>>> collect2: ld returned 1 exit status
>>>
>>> make: *** [testcpp.exe] Error 1
>>>
>>> make: Target `all' not remade because of errors.
>>>
>>> Build complete for project testcpp
>>>
>>>
>>>
>>> Any help is greatly appreciated.
>>>
>>>
>>>
>>> Thanks
>>>
>
>
|
|
|
Re: project dependency and linking [message #137501 is a reply to message #137431] |
Thu, 03 February 2005 21:02  |
Eclipse User |
|
|
|
Originally posted by: john.wang.gmail.com
Yes, GDB is on the path.
I am using Eclipse 3.1 M4, do you think this is the reason?
Thanks
-John
Sean Evoy wrote:
> John,
> It sounds like an environment problem. Is GDB on the path?
> Sean
> John Wang wrote:
>> Thanks Sean!
>> This worked!
>>
>> When I tried to debug my program, I can an "Internal error: Launching"
>> error dialog. I tried with both the cygwin debugger and the gdb
>> debugger, with same error.
>> Any ideas?
>>
>> Thanks
>>
>> -John
>>
>> Sean Evoy wrote:
>>
>>> Hi John,
>>> This will be easy to resolve. First, you have specified the path to
>>> your library correctly, and this is passed to the linker using the -L
>>> flag. The problem is that the linker expects you to specify a library
>>> without the 'lib' prefix and '.a' suffix, so in the library list, just
>>> enter 'testLib' (without the single quotes). The linker argument will
>>> then be
>>
>>
>>> g++ -L"C:jwangworkspacetestLibDebug" -o testcpp.exe test.o
>>> -l"testLib"
>>
>>
>>> and the linker will stop complaining. Hope this helps, and thanks for
>>> posting this on the newsgroup.
>>
>>
>>> Sean
>>
>>
>>> John Wang wrote:
>>>
>>>> Hi:
>>>>
>>>> I have two C++ projects under CDT. One is a static library, e.g.
>>>> testLib which contains a class A.
>>>>
>>>> The other is an .exe project, e.g. testCPP, which has a dependency
>>>> on testLib.
>>>>
>>>> My problem is that testCPP cannot link correctly to testLib, e.g.
>>>> it cannot resolve A. I've added A.h to the include path of testCPP but
>>>> it still could not resolve the objects.
>>>>
>>>> I've set the project reference on testCPP to testLib.
>>>>
>>>> My library is at:
>>>> C:jwangworkspacetestLibDebuglibtestLib.a
>>>>
>>>> When I set the link path and link library switches, I get the
>>>> following errors:
>>>>
>>>> make -k all
>>>>
>>>> Building target: testcpp.exe
>>>>
>>>> g++ -L"C:jwangworkspacetestLibDebug" -o testcpp.exe test.o
>>>> -l"C:jwangworkspacetestLibDebuglibtestLib.a"
>>>>
>>>> /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/../../../../i686-pc-cy gwin/bin/ld:
>>>> cannot find -lC:jwangworkspacetestLibDebuglibtestLib.a
>>>>
>>>> collect2: ld returned 1 exit status
>>>>
>>>> make: *** [testcpp.exe] Error 1
>>>>
>>>> make: Target `all' not remade because of errors.
>>>>
>>>> Build complete for project testcpp
>>>>
>>>>
>>>>
>>>> Any help is greatly appreciated.
>>>>
>>>>
>>>>
>>>> Thanks
>>>>
>>
>>
|
|
|
Goto Forum:
Current Time: Sun May 11 21:01:24 EDT 2025
Powered by FUDForum. Page generated in 0.07283 seconds
|