LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-17-2024, 05:34 AM   #1
rahulvishwakarma
Member
 
Registered: Aug 2010
Posts: 139

Rep: Reputation: 2
How to include shared library build by myself, in CodeBlocks IDE 17.12.


I've CentOS 7 with C++ IDE : Code Blocks 17.12. I Build shared library "libclrscr-getch.so" & header "clrscr-getch.h". I saved these in standard path : for lib "/usr/lib64/clrscr-getch/libclrscr-getch.so" and header in "/usr/include/clrscr-getch/clrscr-getch.h".

In second projct I simply called that shared libarary, by usual way. When I run this in by start button of IDE it works fine, Its working. But when I run this executable in CLI ( terminal ) it shows follwoing error :-

"./clrscr: error while loading shared libraries: libvalidator.so: cannot open shared object file: No such file or directory"

Now I set it's library path in LD_LIBRARY_PATH, it is recognized. and gives right output. Question is : How to add library in location : "/usr/lib64/clrscr-getch".
 
Old 07-17-2024, 06:13 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,923
Blog Entries: 1

Rep: Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885Reputation: 1885
Don't install your experimental programs under /usr/lib64.
Do something like this:
Code:
mkdir ~/lib
libtool --mode=compile gcc -o clrscr.lo clrscr.c
libtool --mode=compile gcc -o getch.lo getch.c
libtool --mode=link gcc -rpath ~/lib -shared -o libclrscr-getch.la clrscr.lo getch.lo
libtool --mode=install cp -f libclrscr-getch.la ~/lib/
libtool --mode=link gcc -o main.exe main.c ~/lib/libclrscr-getch.la
./main.exe

Last edited by NevemTeve; 07-17-2024 at 06:15 AM.
 
1 members found this post helpful.
  


Reply

Tags
c++


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] bool function declaration in header file. Codeblocks tells me I forgot to include stdbool.h jmgibson1981 Programming 14 04-13-2023 06:25 PM
[SOLVED] what include files and libraries do i need to run gtkglext in codeblocks terrorofdeath Linux - Newbie 12 05-13-2013 03:08 PM
[SOLVED] Link shared library against other shared library Lobinho Linux - Newbie 2 05-28-2010 08:16 AM
gcc link shared library against another shared library qcp Linux - Newbie 1 07-25-2008 11:15 AM
Shared object library that uses another shared object library Nightfox Programming 1 02-15-2006 10:00 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration