Different linker error !

Pages: 12
Hi there,

I get the following linker error when I try to print GaliosField elements in my code !.

Undefined symbols:
"galois::GaloisField::~GaloisField()", referenced from:
_main in TEST_7.o
_main in TEST_7.o
"galois::GaloisField::GaloisField(int, unsigned int const*)", referenced from:
_main in TEST_7.o
"galois::operator<<(std::basic_ostream<char, std::char_traits<char> >&, galois::GaloisField const&)", referenced from:
_main in TEST_7.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

I have been searching through the internet for hours and have red lots of solutions but none of them works in this case. Indeed, I don’t know how to thank you if you solve this problem. The part of my code which is the cause of error is as follows :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include "GaloisField.h"
#include "GaloisFieldElement.h"
#include "GaloisFieldPolynomial.h"


/*
   p(x) = 1x^8+1x^7+0x^6+0x^5+0x^4+0x^3+1x^2+1x^1+1x^0
          1    1    0    0    0    0    1    1    1
*/
unsigned int poly[9] = {1,1,1,0,0,0,0,1,1};

/*
  A Galois Field of type GF(2^8)
*/

galois::GaloisField gf(8,poly);


int main(int argc, char *argv[])
{

   std::cout << gf;

//   exit(EXIT_SUCCESS);
   return 0;

}

Show all your project files, please.
closed account (DSLq5Di1)
Are you linking to the Galois Field library?

Show all your project files, please.

Thanks Syuf, for your reply.
Well truly I am simulating a network on ns3. Thus, the other parts of this code is not relevant to this error. But Galois Field library is available in the link below :

http://www.partow.net/projects/galois/index.html

Are you linking to the Galois Field library?


Yes, I have referenced to the project website in the above comment.
Maybe you need to build this library?

Maybe you need to build this library?


Agree...As I downloaded the galios field project files, I put them in a directory and then entered that directory and wrote "make all" command in the terminal. Then there was no problem and I was able to see the output of all files by just opening the relevant makefile. But now in the simulation under ns3, we have a "scratch" folder and we ought to compile our .cc files with "./waf". Therefore, if you write "make all" in the terminal, gcc would tell you something like"there is nothing to make".
Do you have any idea for making/building galios field files in this case ?.
Do you have any idea for making/building galios field files in this case ?

No

Yes, I have referenced to the project website in the above comment.

That's not what "linking" means.

http://en.wikipedia.org/wiki/Linker_%28computing%29
Dear hanst99,
Thank you very much for the link :-)
As I have explained to Syuf, I am simulating under ns3 and I haven't the same problem if I use the Galios Field library in a common c++ script.
Let me also tell you that I've got the same error on both mac os x and ubuntu.

I will be grateful if you help me in solving this problem,
A

---
Answer the question - do you actually link to the galios library?
Although I have understood what the linker is, I cannot understand what do you mean of linking to the galios library...would you mind explaining it more to me ?

Thank you again for your kindness :-).
You can think of a library as a big chunk of precompiled object code. Headers just provide the declarations for functions and datatypes and the like, the actual implementations are put in libraries. Check in your galios folder, somewhere there you should have a lib folder, there you should find one or multiple files with names like
libSOMETHING.a - to link this you have to provide the library path to your linker (on the command line you do this with -L*thepath*, if you use an IDE you can do this in your build options), and then link with -l*SOMETHING* -without the asterisks, and with actual names/paths of course.
Thank you again hanst99 and sorry for my delay :-).

As you mentioned there exist some declarations in the header files but, The implementations have been put in ".cpp" files. I haven't any file with .a extention. The library folder consists of the files below :

GaloisField.cpp GaloisFieldElement.cpp GaloisFieldPolynomial.cpp
GaloisField.h GaloisFieldElement.h GaloisFieldPolynomial.h

Kind Regards,
A


Wait, I just checked it - there is indeed a makefile there.

I am assuming you are using Windows MinGW here, if that is not correct please say so:

go the galois directory, shift+rightclick into it and then select "open command-line here"

now copy&paste the following commands:

mingw32-make
ar rcs libgalois.a GaloisField.o GaloisFieldElement.o GaloisFieldPolynomial.o


if you get a "command not found" error add your mingw binary path to the PATH environment variable like this:

set PATH=%PATH%*PathToMinGW*\bin;

replace *PathToMinGW* with whatever path leads to your MinGW release.

Once you have done that, you should have a libgalois.a file in the folder. Just proceed with that one as I said earlier.

Again, if you are not using Windows with MinGW, please report back.
Last edited on
Thank you very much for taking the time and checking the galois library :-).

Truly I am not using Windows MinGW. I am using Mac OS X but as I mentioned before, I have the same problem on ubuntu. Perhaps the following report which I have written in respond to Syuf would be helpful. If it is not helpful, pardon me...

As I downloaded the galios field project files, I put them in a directory and then entered that directory and wrote "make all" command in the terminal. Then there was no problem and I was able to see the output of all files by just opening the relevant makefile. But now in the simulation under ns3, we have a "scratch" folder and we ought to compile our .cc files with "./waf". Therefore, if you enter scratch and write "make all" in the terminal, gcc would tell you something like "there is nothing to make".

Cheers,
Ali
Ok, what build tools are you using? GCC? Or something Mac OS specific?
I use GCC.
In that case, just type in the "ar" line from my previous post, and proceed from there.
Last edited on
My thanks :-).
I was able to create the libgalois.a in the way you taught me. But when I write -L*libgalois path* in the terminal with asterisks, it says "No such file or directory". If I write it without asterisks, it says "command not found". I have tested on both Mac OS X and ubuntu.
Maybe it is my fault or I am not careful about something.

I appreciate your helps up to now and look forward your new guidance :-).
Last edited on
Pages: 12