Rather noobish c++ question

Lazy8s

Golden Member
Jun 23, 2004
1,503
0
0
Ok, I canNOT figure out what I am doing wrong here. I downloaded a custom library. It includes the files:
aes.h
aes.c

I made a file to test it called Test.cpp

The contents of Test.cpp are:

#include "./aes.h"
#include <iostream>



int main()
{
int a = aes_self_test(1);
}



I have aes.h, aes.cpp and Test.cpp all in the same directory (due to write privelages up here at school). Inside aes.cpp I changed:
#include "aes.h"
to
#include "./aes.h"


The compiler error I am getting is:
Test.cpp:4:
aes.h:95:19: warning: no newline at end of file
/tmp/ccJx2nhi.o: In function `main':
Test.cpp:11: undefined reference to `aes_self_test'
collect2: ld returned 1 exit status



I added a newline (for those of you that will ask) and it still gives the warning, whatever. The problem is I can't figure out why it's saying the reference to the function doesn't exist since it CLEARLY does and it is being used correctly. The link to the aes.h and aes.c code is:
http://xyssl.org/code/source/aes/

I am working on an openSUSE machine if that matters. Thanks much in advance, sorry it's such a noob Q but I have almost 0 experience in C++.

EDIT: If you guys need more info just say. I can provide screenshots or source or whatever.
EDIT2: I just tried on a WinXP machine and it gives the exact same error message. What am I missing here?
 

hg403

Member
Jul 7, 2002
40
0
0
This is a linker issue

I'm not too familiar with linux compiling, but try this at the command line:
g++ -o test test.cpp aes.cpp

In an ide like visual studio, adding aes.h and aes.cpp to the project and then compiling should work
 

aCynic2

Senior member
Apr 28, 2007
710
0
0

If aes.h is in the same directory as Test.cpp, you shouldn't have to specify "./aes.h" to get the compiler to see it...

Using angle brackets means it looks in the environment defined directories. Using quotes means to look in the current directory or perhaps the user defined directories. At least that is always how I understood it.

Lastly, how big is aes.h? Is it something you could post?
 

Lazy8s

Golden Member
Jun 23, 2004
1,503
0
0
It's postable, but if you follow the link it shows you the text. I mean literally, click on the link and it's just a page with the aes.h and aes.c source code.

I solved the problem by just copying aes.c into aes.h at the very end. Then, once I removed my #include "aes.h" from aes.h (whoops) it compiles and runs fine.
 

aCynic2

Senior member
Apr 28, 2007
710
0
0
Originally posted by: Lazy8s
It's postable, but if you follow the link it shows you the text. I mean literally, click on the link and it's just a page with the aes.h and aes.c source code.

I solved the problem by just copying aes.c into aes.h at the very end. Then, once I removed my #include "aes.h" from aes.h (whoops) it compiles and runs fine.

That's not recommended. If you have to use the header in multiple files, you'll have problems.
 

Lazy8s

Golden Member
Jun 23, 2004
1,503
0
0
Yeah I know it's a bad solution. Fortunately I only have to use it once here. If you can think of anything please say.
 

aCynic2

Senior member
Apr 28, 2007
710
0
0
Why are you using a "./" in the include for aes.h anyway?

I'll restate, if it's in the same directory as the project, you shouldn't need to do that.
 

Lazy8s

Golden Member
Jun 23, 2004
1,503
0
0
Originally posted by: aCynic2
Why are you using a "./" in the include for aes.h anyway?

I'll restate, if it's in the same directory as the project, you shouldn't need to do that.

I took the ./ out. with or without it, the same thing occurs.
 

smack Down

Diamond Member
Sep 10, 2005
4,507
0
0
Originally posted by: Lazy8s
Yeah I know it's a bad solution. Fortunately I only have to use it once here. If you can think of anything please say.

It sounds like you need to add aes.c to the make file or g++ compile line. gcc will not compile the .c file unless you tell it to. Can you post your build command and scripts.

Try doing "gcc Test.cpp aes.cpp" and it might compile.

 

aCynic2

Senior member
Apr 28, 2007
710
0
0
Originally posted by: Lazy8s
Originally posted by: aCynic2
Why are you using a "./" in the include for aes.h anyway?

I'll restate, if it's in the same directory as the project, you shouldn't need to do that.

I took the ./ out. with or without it, the same thing occurs.

Then for now, leave it out. It's not helping and it's not standard usage so the problem is elsewhere and you need to figure out where the root problem lies.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |