error while loading shared libraries
Added by Stefano Manni over 13 years ago
Hi everyone I'm new with Wt and I have a problem with my first toy app (Hello world).
I'm using Fedora 16 (Verne) ad wt-3.2.0. Examples contained in the archive work fine.
But a writing a "new" HelloWorld program I get an error during execution.
Here is my CMakeLists.txt:
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
SET(WT_PROJECT_SOURCE
hello.C
)
SET(WT_PROJECT_TARGET hello.wt)
ADD_EXECUTABLE(${WT_PROJECT_TARGET} ${WT_PROJECT_SOURCE})
LINK_DIRECTORIES(/usr/local/lib)
INCLUDE_DIRECTORIES(/usr/local/include/Wt /usr/local/lib)
TARGET_LINK_LIBRARIES(${WT_PROJECT_TARGET} wt wthttp boost_signals-mt)
Code correctly compiles, but launching it with:
sudo ./hello.wt --docroot . --http-address 0.0.0.0 -http-port 8080
I get this error :
./hello.wt: error while loading shared libraries: libwt.so.31: cannot open shared object file: No such file or directory
that changes in:
./hello.wt: error while loading shared libraries: libwthttp.so.31: cannot open shared object file: No such file or directory
if I move 'wt' after 'wthttp' in TARGET_LINK_LIBRARIES(..) CMakeLists.txt file row.
It is apparently a linker problem but ldd gets:
[smanni@fedora obj]$ ldd ./hello.wt
linux-gate.so.1 => (0x00da5000)
libwthttp.so.31 => /usr/local/lib/libwthttp.so.31 (0x009db000)
libwt.so.31 => /usr/local/lib/libwt.so.31 (0x00110000)
libboost_signals-mt.so.1.47.0 => /usr/lib/libboost_signals-mt.so.1.47.0 (0x0069e000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x49820000)
libm.so.6 => /lib/libm.so.6 (0x487ce000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x487fb000)
libc.so.6 => /lib/libc.so.6 (0x485f0000)
libz.so.1 => /lib/libz.so.1 (0x4883c000)
libboost_thread-mt.so.1.47.0 => /usr/lib/libboost_thread-mt.so.1.47.0 (0x00f7d000)
libboost_filesystem-mt.so.1.47.0 => /usr/lib/libboost_filesystem-mt.so.1.47.0 (0x006b4000)
libboost_program_options-mt.so.1.47.0 => /usr/lib/libboost_program_options-mt.so.1.47.0 (0x00f04000)
libboost_date_time-mt.so.1.47.0 => /usr/lib/libboost_date_time-mt.so.1.47.0 (0x006d2000)
libpthread.so.0 => /lib/libpthread.so.0 (0x4879e000)
libboost_random-mt.so.1.47.0 => /usr/lib/libboost_random-mt.so.1.47.0 (0x006e1000)
libboost_regex-mt.so.1.47.0 => /usr/lib/libboost_regex-mt.so.1.47.0 (0x006e5000)
libboost_system-mt.so.1.47.0 => /usr/lib/libboost_system-mt.so.1.47.0 (0x007d8000)
librt.so.1 => /lib/librt.so.1 (0x487c2000)
/lib/ld-linux.so.2 (0x485cb000)
libicuuc.so.46 => /usr/lib/libicuuc.so.46 (0x4bbb3000)
libicui18n.so.46 => /usr/lib/libicui18n.so.46 (0x4b9e2000)
libicudata.so.46 => /usr/lib/libicudata.so.46 (0x4ab6b000)
libdl.so.2 => /lib/libdl.so.2 (0x487bb000)
and I cannot figure out which is the problem in the ldd response.
Any suggestions? Thanks in advance
Replies (10)
RE: error while loading shared libraries - Added by Koen Deforche over 13 years ago
IHey,
You shouldn't sudo. This runs as root which does not have /usr/local/lib in its ld library path.
There is no need either since 8080 is no a privileged port.
Try sudo ldd to see why it fails.
Koen
RE: error while loading shared libraries - Added by Stefano Manni over 13 years ago
Thanks man!!!! It works now
RE: error while loading shared libraries - Added by Wilker Azevedo about 11 years ago
I have the same error. But without sudo too.
I compile using other user and get the error on run.
The libwt.so.38 is in /usr/local/lib but error message says dont when I run as root or any other user.
Have you any suggestions to me?
slackware 14 64bits
kernel 3.2.29
gcc 4.7.1
wt 3.3.3 ¶
RE: error while loading shared libraries - Added by Wilker Azevedo about 11 years ago
Ok, I put a link in /lib/64 and work .... but, when I compile give this error:
/tmp/ccARXQps.o: In function `main':
hello.cpp:(.text+0x3f1): undefined reference to `Wt::WRun(int, char, boost::function<Wt::WApplication* (Wt::WEnvironment const&)>)'
collect2: error: ld returned 1 exit status
I have all dependence installed (boost, ...). I run make in the example hello.wt and work fine. But I create my own hello and don't work!
I comment the "return Wt::WRun(argc, argv, &createApplication);" line in main()... compile ok, but I need the code!
Look the hello file to test:
==
#include
#include
#include
#include
#include
#include
class HelloApplication : public Wt::WApplication
{
public:
HelloApplication(const Wt::WEnvironment& env);
private:
Wt::WLineEdit *nameEdit_;
Wt::WText *greeting_;
void greet();
};
HelloApplication::HelloApplication(const Wt::WEnvironment& env)
: Wt::WApplication(env)
{
setTitle("Hello world");
root()->addWidget(new Wt::WText("Your name, please ? "));
nameEdit_ = new Wt::WLineEdit(root());
Wt::WPushButton *button = new Wt::WPushButton("Greet me.", root());
root()->addWidget(new Wt::WBreak());
greeting_ = new Wt::WText(root());
button->clicked().connect(this, &HelloApplication::greet);
}
void HelloApplication::greet()
{
greeting_setText("Hello there, " + nameEdit_>text());
}
Wt::WApplication *createApplication(const Wt::WEnvironment& env)
{
return new HelloApplication(env);
}
int main(int argc, char **argv)
{
return Wt::WRun(argc, argv, &createApplication);
} ¶
See? It's ok! But don't compile!
RE: error while loading shared libraries - Added by Wim Dumon about 11 years ago
What is the exact command that is used for linking?
What links did you put in /lib/64
BR,
Wim.
RE: error while loading shared libraries - Added by Wilker Azevedo about 11 years ago
I link it using "ln -s /usr/local/lib/libwt.so.38 /lib64/libwt.so.38"
After linking, returns this error while compiling:
/tmp/ccARXQps.o: In function `main':
hello.cpp:(.text+0x3f1): undefined reference to `Wt::WRun(int, char, boost::function<Wt::WApplication* (Wt::WEnvironment const&)>)'
collect2: error: ld returned 1 exit status ¶
But the examples, compile and run fine.
RE: error while loading shared libraries - Added by Koen Deforche about 11 years ago
Hey,
If you get an undefined reference to WRun() it's because you are not linking against wthttp.
Regards,
koen
RE: error while loading shared libraries - Added by Wilker Azevedo about 11 years ago
Tanks!
I will find about this. Have you some info about this? It's my first time "trying" wt and I'm not good in C/C
Tanks again!
RE: error while loading shared libraries - Added by Koen Deforche about 11 years ago
Hey,
A Wt application needs at least two libraries: wt and wthttp. The first one contains the bulk of Wt, the second one implements the web server 'connector' and there are also wtfcgi, wtfcgi or wtisapi which provide alternatives).
In your linker command you thus need (-lwthttp -lwt). How to configure the linker command entirely depends on the how you build Wt; using an IDE or using a build file (Makefile) or using CMake (CMakeLists.txt).
Regards,
koen
RE: error while loading shared libraries - Added by Kris Duraj over 10 years ago
Hey,
I had that same problem.
I resolved this adding "/usr/local/lib" to Additional Library Directories in my project.
In Netbeans IDE you can see where to add on picture that I uploaded.
Regards
Kris