Jump to content

  • Log In with Google      Sign In   
  • Create Account

James Leighe

Member Since 17 Nov 2009
Offline Last Active Jun 25 2013 07:16 PM

Posts I've Made

In Topic: Making a Static Lib in Linux

26 January 2013 - 02:02 AM

I fixed it!
 

It was because I had a define that used __inline (from MSVC) and clang was just ignoring it.

 

Thanks for all your help guys.


In Topic: Making a Static Lib in Linux

25 January 2013 - 11:05 PM

That helped!

Now I just have multiple definition issues. But at least that's more familiar territory.

james@debian:~/Dropbox/Fly Games/project_sophia/test$ clang++ -std=c++0x -I ../libsophia/public/ main.cpp -o build/main -L ../libsophia/build -lsophia
../libsophia/build/libsophia.a(sa_string.o): In function `sa::MemShiftForward(void*, unsigned int, unsigned int, unsigned int)':
sa_string.cpp:(.text+0x160): multiple definition of `sa::MemShiftForward(void*, unsigned int, unsigned int, unsigned int)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x1a0): first defined here
../libsophia/build/libsophia.a(sa_string.o): In function `sa::MemShiftBackward(void*, unsigned int, unsigned int, unsigned int)':
sa_string.cpp:(.text+0x1c0): multiple definition of `sa::MemShiftBackward(void*, unsigned int, unsigned int, unsigned int)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x200): first defined here
../libsophia/build/libsophia.a(sa_string.o): In function `sa::Free(void*)':
sa_string.cpp:(.text+0x80): multiple definition of `sa::Free(void*)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0xc0): first defined here
../libsophia/build/libsophia.a(sa_string.o): In function `sa::Calloc(unsigned int)':
sa_string.cpp:(.text+0x20): multiple definition of `sa::Calloc(unsigned int)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x60): first defined here
../libsophia/build/libsophia.a(sa_string.o): In function `sa::Malloc(unsigned int)':
sa_string.cpp:(.text+0x0): multiple definition of `sa::Malloc(unsigned int)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x40): first defined here
../libsophia/build/libsophia.a(sa_string.o): In function `sa::MemSet(void*, unsigned char, unsigned int)':
sa_string.cpp:(.text+0xa0): multiple definition of `sa::MemSet(void*, unsigned char, unsigned int)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0xe0): first defined here
../libsophia/build/libsophia.a(sa_string.o): In function `sa::MemCopy(void const*, void*, unsigned int)':
sa_string.cpp:(.text+0xe0): multiple definition of `sa::MemCopy(void const*, void*, unsigned int)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x120): first defined here
../libsophia/build/libsophia.a(sa_string.o): In function `sa::MemMove(void*, void*, unsigned int)':
sa_string.cpp:(.text+0x120): multiple definition of `sa::MemMove(void*, void*, unsigned int)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x160): first defined here
../libsophia/build/libsophia.a(sa_string.o): In function `sa::Realloc(void*, unsigned int)':
sa_string.cpp:(.text+0x50): multiple definition of `sa::Realloc(void*, unsigned int)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x90): first defined here
../libsophia/build/libsophia.a(sa_string.o): In function `unsigned int samath::RoundUpToPowerOfTwo<unsigned int>(unsigned int)':
sa_string.cpp:(.text+0x210): multiple definition of `unsigned int samath::RoundUpToPowerOfTwo<unsigned int>(unsigned int)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x250): first defined here
../libsophia/build/libsophia.a(sa_string.o): In function `double samath::Random<double>(double, double)':
sa_string.cpp:(.text+0x360): multiple definition of `double samath::Random<double>(double, double)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x3a0): first defined here
../libsophia/build/libsophia.a(sa_string.o): In function `float samath::Random<float>(float, float)':
sa_string.cpp:(.text+0x290): multiple definition of `float samath::Random<float>(float, float)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x2d0): first defined here
../libsophia/build/libsophia.a(sa_random.o): In function `sa::MemShiftForward(void*, unsigned int, unsigned int, unsigned int)':
sa_random.cpp:(.text+0x160): multiple definition of `sa::MemShiftForward(void*, unsigned int, unsigned int, unsigned int)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x1a0): first defined here
../libsophia/build/libsophia.a(sa_random.o): In function `sa::MemShiftBackward(void*, unsigned int, unsigned int, unsigned int)':
sa_random.cpp:(.text+0x1c0): multiple definition of `sa::MemShiftBackward(void*, unsigned int, unsigned int, unsigned int)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x200): first defined here
../libsophia/build/libsophia.a(sa_random.o): In function `sa::Free(void*)':
sa_random.cpp:(.text+0x80): multiple definition of `sa::Free(void*)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0xc0): first defined here
../libsophia/build/libsophia.a(sa_random.o): In function `sa::Calloc(unsigned int)':
sa_random.cpp:(.text+0x20): multiple definition of `sa::Calloc(unsigned int)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x60): first defined here
../libsophia/build/libsophia.a(sa_random.o): In function `sa::Malloc(unsigned int)':
sa_random.cpp:(.text+0x0): multiple definition of `sa::Malloc(unsigned int)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x40): first defined here
../libsophia/build/libsophia.a(sa_random.o): In function `sa::MemSet(void*, unsigned char, unsigned int)':
sa_random.cpp:(.text+0xa0): multiple definition of `sa::MemSet(void*, unsigned char, unsigned int)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0xe0): first defined here
../libsophia/build/libsophia.a(sa_random.o): In function `sa::MemCopy(void const*, void*, unsigned int)':
sa_random.cpp:(.text+0xe0): multiple definition of `sa::MemCopy(void const*, void*, unsigned int)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x120): first defined here
../libsophia/build/libsophia.a(sa_random.o): In function `sa::MemMove(void*, void*, unsigned int)':
sa_random.cpp:(.text+0x120): multiple definition of `sa::MemMove(void*, void*, unsigned int)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x160): first defined here
../libsophia/build/libsophia.a(sa_random.o): In function `sa::Realloc(void*, unsigned int)':
sa_random.cpp:(.text+0x50): multiple definition of `sa::Realloc(void*, unsigned int)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x90): first defined here
../libsophia/build/libsophia.a(sa_stringtools.o): In function `sa::MemShiftForward(void*, unsigned int, unsigned int, unsigned int)':
sa_stringtools.cpp:(.text+0x160): multiple definition of `sa::MemShiftForward(void*, unsigned int, unsigned int, unsigned int)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x1a0): first defined here
../libsophia/build/libsophia.a(sa_stringtools.o): In function `sa::MemShiftBackward(void*, unsigned int, unsigned int, unsigned int)':
sa_stringtools.cpp:(.text+0x1c0): multiple definition of `sa::MemShiftBackward(void*, unsigned int, unsigned int, unsigned int)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x200): first defined here
../libsophia/build/libsophia.a(sa_stringtools.o): In function `sa::Free(void*)':
sa_stringtools.cpp:(.text+0x80): multiple definition of `sa::Free(void*)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0xc0): first defined here
../libsophia/build/libsophia.a(sa_stringtools.o): In function `sa::Calloc(unsigned int)':
sa_stringtools.cpp:(.text+0x20): multiple definition of `sa::Calloc(unsigned int)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x60): first defined here
../libsophia/build/libsophia.a(sa_stringtools.o): In function `sa::Malloc(unsigned int)':
sa_stringtools.cpp:(.text+0x0): multiple definition of `sa::Malloc(unsigned int)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x40): first defined here
../libsophia/build/libsophia.a(sa_stringtools.o): In function `sa::MemSet(void*, unsigned char, unsigned int)':
sa_stringtools.cpp:(.text+0xa0): multiple definition of `sa::MemSet(void*, unsigned char, unsigned int)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0xe0): first defined here
../libsophia/build/libsophia.a(sa_stringtools.o): In function `sa::MemCopy(void const*, void*, unsigned int)':
sa_stringtools.cpp:(.text+0xe0): multiple definition of `sa::MemCopy(void const*, void*, unsigned int)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x120): first defined here
../libsophia/build/libsophia.a(sa_stringtools.o): In function `sa::MemMove(void*, void*, unsigned int)':
sa_stringtools.cpp:(.text+0x120): multiple definition of `sa::MemMove(void*, void*, unsigned int)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x160): first defined here
../libsophia/build/libsophia.a(sa_stringtools.o): In function `sa::Realloc(void*, unsigned int)':
sa_stringtools.cpp:(.text+0x50): multiple definition of `sa::Realloc(void*, unsigned int)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x90): first defined here
../libsophia/build/libsophia.a(sa_stringtools.o): In function `unsigned int samath::RoundUpToPowerOfTwo<unsigned int>(unsigned int)':
sa_stringtools.cpp:(.text+0x210): multiple definition of `unsigned int samath::RoundUpToPowerOfTwo<unsigned int>(unsigned int)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x250): first defined here
../libsophia/build/libsophia.a(sa_stringtools.o): In function `double samath::Random<double>(double, double)':
sa_stringtools.cpp:(.text+0x360): multiple definition of `double samath::Random<double>(double, double)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x3a0): first defined here
../libsophia/build/libsophia.a(sa_stringtools.o): In function `float samath::Random<float>(float, float)':
sa_stringtools.cpp:(.text+0x290): multiple definition of `float samath::Random<float>(float, float)'
/tmp/main-lSPKsO.o:main.cpp:(.text+0x2d0): first defined here
../libsophia/build/libsophia.a(sa_random.o): In function `sa::Random::Seed(unsigned int)':
sa_random.cpp:(.text+0x29a): undefined reference to `sfmt_init_gen_rand'
../libsophia/build/libsophia.a(sa_random.o): In function `sfmt_genrand_uint32':
sa_random.cpp:(.text+0x2fd): undefined reference to `sfmt_gen_rand_all'
../libsophia/build/libsophia.a(sa_random.o): In function `sfmt_genrand_uint64':
sa_random.cpp:(.text+0x3d9): undefined reference to `sfmt_gen_rand_all'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

 

It could be I made a mistake when moving over form "#pragma once" to the ifndef method somewhere but I tried to be careful and like I said in MSVC it builds without a warning.

 

Progress!


In Topic: Making a Static Lib in Linux

25 January 2013 - 09:50 PM

Hmm, still no dice it would seem.

 

Here is how I compile the sophia static library:

clang++ -std=c++0x -c sa_math.cpp		-o build/sa_math.o
clang++ -std=c++0x -c sa_sophia.cpp		-o build/sa_sophia.o
clang++ -std=c++0x -c sa_stringtools.cpp	-o build/sa_stringtools.o
clang++ -std=c++0x -c sa_string.cpp		-o build/sa_string.o
clang++ -std=c++0x -c sa_baseapplication.cpp	-o build/sa_baseapplication.o
clang++ -std=c++0x -c sa_random.cpp		-o build/sa_random.o
In file included from sa_random.cpp:4:
In file included from ./SFMT-src-1.4/SFMT.h:67:
./SFMT-src-1.4/SFMT-params.h:7:4: warning: #warning "SFMT_MEXP is not defined. I assume MEXP is 19937." [-W#warnings]
  #warning "SFMT_MEXP is not defined. I assume MEXP is 19937."
   ^
1 warning generated.
ar rcs build/libsophia.a		\
		build/sa_math.o			\
		build/sa_sophia.o		\
		build/sa_stringtools.o		\
		build/sa_string.o		\
		build/sa_baseapplication.o	\
		build/sa_random.o

 

 

Here is what happens when I attempt to compile the test application:

clang++ -std=c++0x -I ../libsophia/public/ -L ../libsophia/build -lsophia  main.cpp		-o build/main
/tmp/main-bh2HIY.o: In function `main':
main.cpp:(.text+0x48e): undefined reference to `sa::Random::Random()'
main.cpp:(.text+0x49c): undefined reference to `sa::Random::Seed(unsigned int)'
main.cpp:(.text+0x4c8): undefined reference to `sa::Random::GetFloat64(double, double)'
main.cpp:(.text+0x4f9): undefined reference to `sa::Random::GetFloat64(double, double)'
main.cpp:(.text+0x52a): undefined reference to `sa::Random::GetFloat64(double, double)'
main.cpp:(.text+0x57a): undefined reference to `sa::String::GetCString() const'
main.cpp:(.text+0x5bd): undefined reference to `sa::String::~String()'
main.cpp:(.text+0x5dd): undefined reference to `sa::Random::~Random()'
main.cpp:(.text+0x617): undefined reference to `sa::String::~String()'
main.cpp:(.text+0x629): undefined reference to `sa::Random::~Random()'
/tmp/main-bh2HIY.o: In function `sa::Vector3<float>::GetString(int) const':
main.cpp:(.text._ZNK2sa7Vector3IfE9GetStringEi[_ZNK2sa7Vector3IfE9GetStringEi]+0x27): undefined reference to `sa::String::String()'
main.cpp:(.text._ZNK2sa7Vector3IfE9GetStringEi[_ZNK2sa7Vector3IfE9GetStringEi]+0x4e): undefined reference to `sa::String::Copy(float const*, unsigned int, unsigned int)'
main.cpp:(.text._ZNK2sa7Vector3IfE9GetStringEi[_ZNK2sa7Vector3IfE9GetStringEi]+0x82): undefined reference to `sa::String::~String()'
main.cpp:(.text._ZNK2sa7Vector3IfE9GetStringEi[_ZNK2sa7Vector3IfE9GetStringEi]+0x90): undefined reference to `sa::String::~String()'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [all] Error 1

 

 

I'm only testing it by instantiating an instance of the Random class and using it to fill a Vector3 (which is a template and so has no linking issues).

String is popping up because I try and get a String of the Vector's values to print out.

 

So I think everything that could be undefined is undefined.


In Topic: Making a Static Lib in Linux

25 January 2013 - 09:26 PM

OK! We made some progress, now "nm" gives the proper results.

 

However, I'm still getting the same amount of undefined references somehow. Am I linking to the lib properly in the "clang++" call?

 

 

I should also mention that this code is working in windows, so I'm pretty sure it's not a code error.


In Topic: Debugging 3DSMax Plugins

30 December 2012 - 09:45 AM

Wow, that works for some reason!


Thanks allot.


PARTNERS