User forums > Using Code::Blocks
How do I create shared library step by step.
str0g:
Hello
os: ubuntu 9.10 x64
I would like to create shared library
I use creator to create project ProjExec which is console app(only contains main with return 0) and ProSlib which is shared library:
I configured:
ProSlib:
Project->Set programs and arguements->This prog provides main executable [checked] and I set path to [Generated binary from ProjExec]
ProjExec:
ProjExec->properties->projcet's dependecis->ProExec depends on ProSlib.
If I would like to build my ProSlib I got this output
-------------- Build: Debug in ProjSlib ---------------
Linking dynamic library: bin/Debug/libProjSlib.so
/usr/bin/ld: obj/Debug/main.o: relocation R_X86_64_32 against `__gxx_personality_v0' can not be used when making a shared object; recompile with -fPIC
obj/Debug/main.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings
What I did wrong or didn't do to get this compiled and working?
stahta01:
I have no idea what you did wrong;
If you turn on full compiler logging and post the build log where an expert on building this library can read it. They should see the problem.
http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F
Tim S.
oBFusCATed:
Most probably you're building c++ code with the c compiler.
Remember that the file extension matters => .c files are compiled by c compiler, .cpp files by c++ compiler.
Zini:
Actually, the linker seems to tell you very clearly, what you did wrong and what you should do to fix the problem.
--- Quote ---/usr/bin/ld: obj/Debug/main.o: relocation R_X86_64_32 against `__gxx_personality_v0' can not be used when making a shared object; recompile with -fPIC
--- End quote ---
str0g:
Thanks for fast answer.
recompile with -fPIC I have not idea guide me please.
My files are cpp
That was full command line output :/
Googling gave me no solution which I know how to use...
http://code.google.com/p/gosu/issues/detail?id=38
I have g++ 4.4 with multilib
Exec main.cpp
--- Code: ---///Headers
#include <cstdlib>
#include <iostream>
#include <string>
///Specials
using namespace std;
///Globals Varuabels
int main(){
return 0;
}
--- End code ---
Slib main.cpp
--- Code: ---#ifdef __cplusplus
extern "C" {
#endif
// A function adding two integers and returning the result
int SampleAddInt(int i1, int i2)
{
return i1 + i2;
}
// A function doing nothing ;)
void SampleFunction1()
{
// insert code here
}
// A function always returning zero
int SampleFunction2()
{
// insert code here
return 0;
}
#ifdef __cplusplus
}
#endif
--- End code ---
Navigation
[0] Message Index
[#] Next page
Go to full version