473,395 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Problem compiling SHARED libraries

Hi everyone!
I've got such a problem, that I'm using Kdevelop 3. Kdevelop offer only cmake for compiling with shared library support. So it uses CMakeLists.txt as config file for that
Expand|Select|Wrap|Line Numbers
  1. #add definitions, compiler switches, etc.
  2. ADD_DEFINITIONS(-Wall -O2 -L)
  3.  
  4. #build a shared library
  5. ADD_LIBRARY(test2 SHARED test2.cpp)
  6.  
  7. #for testing the shared library you probably need some test app too
  8. ADD_EXECUTABLE(test2test test2test.cpp)
  9.  
  10. #need to link to some other libraries ? just add them here
  11. TARGET_LINK_LIBRARIES(test2test test2)
Thats an example. It works. But, I cannot move the program. It always looks for that shared library ONLY where it was created. How this problem could be solved? Help please, someone!
Aug 11 '08 #1
8 1939
gpraghuram
1,275 Expert 1GB
I can understand the issue fully.
Are you saying that the .so is not being looked up properly or you want that to look for the .so in a different directory?

Raghu
Aug 12 '08 #2
Actually I need to "unlock" it. I don't want it looking for ablosute adress based dependecies. I need something like that: ./libs or something like that. It will be a Web based programm. So for users it will be impossible to install libraries to exact place. It would be good, if it was possible to make executable to look for libraries in the same folder, where executable is run.

And yes, programm must depend on *.so files by idea. I don't want there to be all in one executable. Shared libraries are required.

PS. I'm soory for my broken English.
Aug 12 '08 #3
gpraghuram
1,275 Expert 1GB
Actually I need to "unlock" it. I don't want it looking for ablosute adress based dependecies. I need something like that: ./libs or something like that. It will be a Web based programm. So for users it will be impossible to install libraries to exact place. It would be good, if it was possible to make executable to look for libraries in the same folder, where executable is run.

And yes, programm must depend on *.so files by idea. I don't want there to be all in one executable. Shared libraries are required.

PS. I'm soory for my broken English.

If you want to have a single executable accessible via web then go for a static library in which the library gets bundled with the executable.

Raghu
Aug 13 '08 #4
I guess, that I have explained something wrog... Look... Executable and *.so files are written by me and all together only they work as a programm. I need a help with CMake directives. It has to compile libraries(actually it compiles secondary *.cpp as SHARED (*.so)). But the problem is, that after compiling it makes executable to search for libraries in the static adress(for exaple my project's files are in folder /Arhiv/Devel/someproject/). And if I move executable and libraries(*.so files) to (for example) /Programm/ it crashes with erroe that it can't find *.so files.

So I don't need Only exexutable file, I need executable with shared libraries. I guess so, that there is an error during compilation process.

How to make it work properly?
Aug 13 '08 #5
gpraghuram
1,275 Expert 1GB
I guess, that I have explained something wrog... Look... Executable and *.so files are written by me and all together only they work as a programm. I need a help with CMake directives. It has to compile libraries(actually it compiles secondary *.cpp as SHARED (*.so)). But the problem is, that after compiling it makes executable to search for libraries in the static adress(for exaple my project's files are in folder /Arhiv/Devel/someproject/). And if I move executable and libraries(*.so files) to (for example) /Programm/ it crashes with erroe that it can't find *.so files.

So I don't need Only exexutable file, I need executable with shared libraries. I guess so, that there is an error during compilation process.

How to make it work properly?

Then you have to set the LD_LIBRARY_PATH properly for this.
Usually when the executable loads it looks for the .so in the paths given in LD_LIBRARY_PATH...

Raghu
Aug 14 '08 #6
Yes, that's the thing I really need to do.

Could you give some example? (cmake config file is shown at first post).

Thanx for help.
Aug 14 '08 #7
gpraghuram
1,275 Expert 1GB
Yes, that's the thing I really need to do.

Could you give some example? (cmake config file is shown at first post).

Thanx for help.

I think you shuld do it in the variable TARGET_LINK_LIBRARIES.
Add the path of the libraries to LD_LIBRARY_PATH.


raghu
Aug 15 '08 #8
So, I've got to read LOTS of manual. Currently started using MonoDevelop for linux(just because it's more comfortable for huge projects). And currently programm works perfectly. The solution is to add custom linker tag
Expand|Select|Wrap|Line Numbers
  1. -Wl,-rpath,'$ORIGIN/.libs'
This command makes executable to search for llibraries in execution directory/.libs .
$ORIGIN = current directory
So it will find libs in "./.libs/"

Huge thanks to everyone!
Answer is written in case if someone has simmilar problem.
PS. For more detailed information see "man ld.so"
Aug 19 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Mike S. | last post by:
Hello, Has anyone had success compiling the informixdb-1.3 module under python 2.2? It seems the absense of makefile.pre.in in python 2.2 causes the break under py2.2. Is there an easy way...
2
by: Lindon | last post by:
Until now I've been programming straight console apps, and all I've been doing to compile is a simple 'gcc file1.cpp file2.cpp ....'. What more is there to know about the compiler? I'd like to know...
5
by: rsparapa | last post by:
I've been working on vector/matrix/PRNG class libraries for years, but I never got around to figuring out how to make them into libraries; I'm a statistician, not a computer scientist. So, for...
0
by: Kirt Loki Dankmyer | last post by:
So, I download the latest "stable" tar for perl (5.8.7) and try to compile it on the Solaris 8 (SPARC) box that I administrate. I try all sorts of different switches, but I can't get it to compile....
1
by: Sathiamoorthy Balasubramaniyan | last post by:
hello, Iam trying to install postgres-7.4.1 on my tru64 (O.S version 5.1A) box without the shared library support. Here's my list of commands: ../configure --with-includes=/opt/gcc-33/include...
1
by: w chun | last post by:
i've built a Python 2.5a0 interpreter on my iBook using gcc 3.3-1666 using the tarball from last nite... $ uname -a Darwin myMac.local 7.9.0 Darwin Kernel Version 7.9.0: Wed Mar 30 20:11:17 PST...
0
by: follower | last post by:
This post is mostly Google-bait for anyone else that might want to compile SpiderMonkey ( libjs / libjs.so / libjs.dylib ) for OS X (10.4.5 in my case) and then use it with Python's ctypes. I can't...
4
by: Lars | last post by:
Hi, I have problems building a simple handcoded C-extension (hello.c) with Cygwin and gcc3.4.4. I hope somebody has encountered the same problem before, and has some advice. The extension...
1
by: fsmountain | last post by:
Hi guys, I am trying to compile VTK5.0 with Qt GUI Support in Windows 2000 that has Qt Open-Sourced 4.1.2 and CMake 2.4.2 installed. After QVTK is enabled in CMake, configuring it will prompt...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.