User forums > Using Code::Blocks

How to solve the “error:undefined reference to 'xxx' ” although 'xxx' exists

(1/2) > >>

wanggaoteng:
Hi, there is an example in my textbook, it contains three files: main.c, readline.c and readline.h.
I build the project as picture 1 illustrated, and I'm sure no spelling mistake exists.
But when I compiling the project using codeblocks, an error appeared always: undefined reference to 'read_line', as the picture 0 illustrated.(readline.c contains the function definition of 'read_line()')
I checked the project carefully, I think no inappropriate exists (#include "readline.h" has added in main.c). When I move the function definition of read_line() to main.c, and compiling, then no error appeared.
How to fix this problem?
Best regards.

stahta01:
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

Make sure you are using an CB Project. If yes, post the full rebuild log.

Tim S.

wanggaoteng:

--- Quote from: stahta01 on February 14, 2019, 02:00:52 pm ---http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

Make sure you are using an CB Project. If yes, post the full rebuild log.

Tim S.

--- End quote ---
Hi, Tim,
I use the CB project, and the full rebuild log as the picture 2 illustrated.
I upload the whole project (test.rar) in the attachment.
Thank you.
P.S. My CB is codeblocks-17.12mingw-setup.exe

stahta01:
Post the full rebuild in code tags.
And, make sure the second file is part of the project.

Tim S.

stahta01:
Add readline.c to the targets Release and Debug

Edit:
Select readline.c file
File Properties
Tab: Build

Tim S.

Navigation

[0] Message Index

[#] Next page

Go to full version