Problem while building a Class

0 Bhavesh B · May 18, 2015
Hi,

Can some one help me with this Error:
-------------- Build: Debug in Houzup (compiler: GNU GCC Compiler)---------------

g++ -Wall -fexceptions -g -I -c /Users/AdminPC/Documents/HOUZUP/Codeblocks/Houzup/main.cpp -o obj/Debug/main.o
Undefined symbols for architecture x86_64:
  "Vegan::Vegan()", referenced from:
      _main in main-cafab0.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

NOTE: i am using macbook air

Post a Reply

Replies

Oldest  Newest  Rating
0 Dol Lod · May 18, 2015
Without actual code nobody, can help. 
0 Sengngy Kouch · May 18, 2015
Seem like you having trouble with you class declaration or something, but please post your code. 

Posting your error is like offering us to find a key in the sea.
0 Bhavesh B · May 19, 2015
/images/forum/upload/2015-05-19/3f82b57dc774e326b8553c159916c1fa.png/images/forum/upload/2015-05-19/f1df49964a956ce3031911d5c93ca95a.png/images/forum/upload/2015-05-19/f3750bc06f36218de2dfed117f68df32.png

Hi Guys, I am sure this will help in helping me ...
I keep getting Error: ||=== Build: Debug in Houzup (compiler: GNU GCC Compiler) ===|
/Users/AdminPC/Documents/HOUZUP/Mango.h|1|error: unterminated conditional directive|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
0 Michael Bradford · May 19, 2015
Hey, did you place your class in a project? This looks like a linker problem to me (a linker is what "links" all the files in a class together so if you haven't made a project OR created a make file then the compiler doesn't know what to do with the includes.

Simplest answer is to make a project and then add those files to a project for your IDE, or you could go complicated and learn about make files, linking etc. 

(In my opinion you should avoid this for now if you're just learning about classes and just use a project as that is most likely what you will be doing usually anyway) [A make file is just basically doing what a project does but manually, it's an unnecessarily complicated topic if you're just starting classes].

BTW: I can tell it's a linker problem because in the first error "error: linker command failed with exit code 1" which essentially means it failed to link properly. All the other things talk about "symbols" which are part of linking files together into object code and executable code which further points to linker problems.
+1 Dol Lod · May 19, 2015
You are missing a #endif at the end of your header files. That is probably what is causing the error.

The last line of code at the end of a header file is #endif

Additionally for good form, you should not be using namespace std inside a header file and should instead be using std::
0 Michael Bradford · May 19, 2015
Arjun is absolutely right, I should've looked at the second error more closely, 
"unterminated conditional directive" is referencing a conditional (if, else) preprocessor directive [the defines in the header]
since you never end the preprocessor directive the program fails on preprocessing.
[It should be noted this is still a linker problem as that's what's doing the preprocessing but more specifically it's not because your files aren't in a project or makefile].
Thanks Mr Patel.
0 Bhavesh B · May 19, 2015
Hi Arjun, 
It worked. Thanks a ton Bro..

Hi Michael,
Thanks so much for looking into my problem and advise.

Thank you guys..
0 Sengngy Kouch · May 19, 2015
@Bhavesh B: your second question is completely different from the first one. Did you manage to solve the first one?
0 Bhavesh B · May 26, 2015
@ Sengngy Kouch, yes bro i was able to work around a way to my problem in the first question.

Thank You :-)
  • 1

C++

107,051 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator