News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Compiler error

Started by Drakonaut, June 03, 2015, 09:51:46 PM

Previous topic - Next topic

Drakonaut

Hi, I'm facing a problem here.

I am running Code::Blocks version Code::Blocks 13.12 on Windows 7 HP
(version OperatingSystemVersionNumber). The compiler I use is TDM-GCC
version 4.7.1.

Description of problem.
My project files fail to compile. Googling tells me that the problem seems to lie with the header file. I followed the steps by un-checking both "Compile" and "Link" boxes but the code gives me this error instead. I deleted all .gch files from the folder too.

Build log:

mingw32-g++.exe  -o bin\Debug\C9E4.exe obj\Debug\main.o obj\Debug\namespace.o   
obj\Debug\main.o: In function `main':
C:/Users/Drakonaut/Desktop/Chapter 9 Ex1/C9E4/main.cpp:11: undefined reference to `SALES::setSales(SALES::Sales&, double const*, int)'
C:/Users/Drakonaut/Desktop/Chapter 9 Ex1/C9E4/main.cpp:12: undefined reference to `SALES::setSales(SALES::Sales&)'
C:/Users/Drakonaut/Desktop/Chapter 9 Ex1/C9E4/main.cpp:13: undefined reference to `SALES::showSales(SALES::Sales const&)'
C:/Users/Drakonaut/Desktop/Chapter 9 Ex1/C9E4/main.cpp:14: undefined reference to `SALES::showSales(SALES::Sales const&)'
collect2.exe: error: ld returned 1 exit status


I read some threads on this forum and some faced the same problem as me. I've got my main.cpp and namespace.cpp linked and compiled. However, it doesn't seem to solve the problem.
Oh, there are these "C9E4.depend" and "C9E4.layout". But I think it isn't related to the problem.
I cut out the "bin" and "obj" and let the compiler re-compile, but the problem is still there.

Thanks!

oBFusCATed

Have you read the link I've pasted you in the other topic?
Do you have definitions (body) for the functions that the linker is reporting as undefined?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Drakonaut

Yes, I've read that but it doesn't solve my problem (Q: My build fails with multiple undefined reference errors?).

So I thought I would look at the error and realise that my functions are in the SALES namespace, but I had forgotten to put them in the curly braces.

Thanks for your help though!  :)