User forums > Using Code::Blocks

[SOLVED] Meeting problem of ‘undefined reference to'

(1/3) > >>

lukenothing:
Hello,

I'm just using Code::Blocks 10.05 on Ubuntu 12.04(precise) 64-bit few days.

Firstly, I created a c++ console project called A in /home/test/ccc/, then I created a C static library project called B which includes serveral files: libabc.a, abc.c, abc.h, etc. in  /home/test/abc/

I tired to using the /home/test/abc/libabc.a created by B in A.

But the ide always show the message as title 'undefined reference to ....'

I searched online and operated as most of them suggested as below:
1) right click the project A, and selected 'Build options',
2) click 'Linker settings' tab and click the 'add' button, pick the /home/test/abc/libabc.a from the prject B directionary,
3) click 'Search directories' tab and under in the sub-tab 'complier', there is an 'add' button, click it as well to select the 'abc.h'

That is all. I even add the /home/test/abc to the 'Search directories-Linker' list, the issure is still alive.

Could you help me?

MortenMacFly:

--- Quote from: lukenothing on December 13, 2012, 09:10:55 am ---3) click 'Search directories' tab and under in the sub-tab 'complier', there is an 'add' button, click it as well to select the 'abc.h'

--- End quote ---
You don't have to select the include file, but the path to the include file, so the compiler is able to find it.

lukenothing:
Sorry about the time you wasted of, I just address the problem which is that after I add the libabc.a to the 'Link libraries', I also need to add an option to 'Other linker options' under the 'Linker settings', such as 'abc'.

Now the 'undefined reference to ...' is gone, but I get a new problem" g++: error: abc: No such file or directory'

lukenothing:

--- Quote from: MortenMacFly on December 13, 2012, 09:19:57 am ---
--- Quote from: lukenothing on December 13, 2012, 09:10:55 am ---3) click 'Search directories' tab and under in the sub-tab 'complier', there is an 'add' button, click it as well to select the 'abc.h'

--- End quote ---
You don't have to select the include file, but the path to the include file, so the compiler is able to find it.

--- End quote ---
Sorry, I make a mistake in description, you right, it'm impossible to add any .h files in that tab, the 'directories' is the only thing it accesses.

lukenothing:
It seems that I did not really solve the problem...

Navigation

[0] Message Index

[#] Next page

Go to full version