Comments (18)
Hi,
it needs -lrt at the compile line:
gcc -o a a.c -I$ONION_DIR/src/ -L$ONION_DIR/src/onion/
-L$ONION_DIR/src/handlers/ -lonion_handlers -lonion_static -lpam -lgnutls
-lgcrypt -lpthread -lrt
For a first example, try better without SSL, this way is easier to debg
(remove the onion_set_certificate line).
I will fix the instructions ASAP.
Regards,
David.
2014/1/21 Gideon Israel Dsouza [email protected]
I'm really looking forward to using onion, I just wanted to compile this
sample from here (http://coralbits.com/static/onion/)#include <onion/onion.h>
#include <onion/handlers/exportlocal.h>
#include <onion/handlers/auth_pam.h>
int main(int argc, char **argv){
onion *o=onion_new(O_THREADED);
onion_set_certificate(o, O_SSL_CERTIFICATE_KEY, "cert.pem", "cert.key", O_SSL_NONE);
onion_set_root_handler(o, onion_handler_auth_pam("Onion Example", "login", onion_handler_export_local_new(".")));
onion_listen(o);
onion_free(o);
return 0;
}The instructions say do this:
gcc -o a a.c -I$ONION_DIR/src/ -L$ONION_DIR/src/onion/
-L$ONION_DIR/src/handlers/ -lonion_handlers -lonion_static -lpam -lgnutls
-lgcrypt -lpthreadBut this is what happens on my machine:
$ gcc -o a a.c -I$ONION_DIR/src/ -L$ONION_DIR/src/onion/ -L$ONION_DIR/src/handlers/ -L/usr/share -lonion_handlers -lonion_static -lpam -L/usr/lib64/libgnutls.so -L/usr/lib64/libgcrypt.so -lpthread
/usr/bin/ld: /usr/local/lib/libonion_static.a(sd-daemon.c.o): undefined reference to symbol 'mq_getattr@@GLIBC_2.3.4'
/usr/bin/ld: note: 'mq_getattr@@GLIBC_2.3.4' is defined in DSO /lib64/librt.so.1 so try adding it to the linker command line
/lib64/librt.so.1: could not read symbols: Invalid operationcollect2: error: ld returned 1 exit status
Any help will really be appreciated!
β
Reply to this email directly or view it on GitHubhttps://github.com//issues/53
.
David Moreno Montero
[email protected]
+34 658 18 77 17
+44 74 23 21 01 57
http://www.coralbits.com/
http://www.coralbits.com
from onion.
Instead of -lonion_static
try -lonion
.
With static linking, in newer gcc, you would have to enumerate every dependencies of libonion_static.a.
from onion.
@davidmoreno I tried that and I get the following:
$ gcc -o a a.c -I$ONION_DIR/src/ -L$ONION_DIR/src/onion/ -L$ONION_DIR/src/handlers/ -L/usr/share lonion_handlers -lonion_static -lpam -lgnutls -lgcrypt -lpthread -lrt
/tmp/ccfKJFqI.o: In function `main':
a.c:(.text+0x5b): undefined reference to `onion_handler_auth_pam'
collect2: error: ld returned 1 exit status
For -lonion
I get :
$ gcc -o a a.c -lonion
/tmp/ccaC5znc.o: In function `main':
a.c:(.text+0x49): undefined reference to `onion_handler_export_local_new'
a.c:(.text+0x5b): undefined reference to `onion_handler_auth_pam'
collect2: error: ld returned 1 exit status
Any ideas?
from onion.
Your libonion was not compiled with Pam support, set ONION_USE_PAM
to true through ccmake or cmake-gui.
Even though ONION_USE_PAM
is setted to true, if cmake fail to find libpam and libpam_misc it will not compile libonion with PAM support, run cmake and verify if it did not output pam not found. No PAM support.
from onion.
Correct. I installed PAM after I built onion. I'll try this again first
thing tomorrow and update this thread.
On Tuesday, January 21, 2014, AndrΓ© Puel [email protected] wrote:
Your libonion was not compiled with Pam support, set ONION_USE_PAM to
true through ccmake or cmake-gui.Even though ONION_USE_PAM is setted to true, if cmake fail to find libpam
and libpam_misc it will not compile libonion with PAM support, run cmake
and verify if it did not output pam not found. No PAM support.β
Reply to this email directly or view it on GitHubhttps://github.com//issues/53#issuecomment-32910066
.
from onion.
So I recompiled onion:
-- libxml2 found. WebDAV support is compiled in.
-- pam found. PAM support is compiled in in handlers.
-- libpng found. png support is compiled in at extras.
But now this happens:
[gideon@gideon-fedora c_stuff]$ gcc -o a a.c -L../onion/build/src/onion/libonion.so -L../onion/build/src/onion/handlers/libonion_handlers.so -lonion_handlers -lonion_static -lpam -lgnutls -lgcrypt -lpthread -lrt
[gideon@gideon-fedora c_stuff]$ ./a
./a: error while loading shared libraries: libonion_handlers.so: cannot open shared object file: No such file or directory
Any ideas?
from onion.
Yes, added the following to the command line you are using to compile:
-Wl,-rpath,$PWD/../onion/build/src/onion/libonion.so -Wl,-path,$PWD/../onion/build/src/onion/handlers/libonion_handlers.so
Explanation: libonion.so and libonion_handler.so are not in standard library lookup directories (/usr/lib
,/lib
, etc), so when you try to run a.out
the runtime linker can not find the libonion.so and libonion_handler.so that a.out says it needs. So, the command line -Wl
means "Pass the following command do the compile-time linker", and -rpath
embeds an extra lookup directory in the a.out executable.
So when the runtime linker is opening a.out it will use the extra directories to search for the a.out dependencies.
from onion.
What should the whole thing look like:
?
gcc -o a a.c -L../onion/build/src/onion/libonion.so -L../onion/build/src/onion/handlers/libonion_handlers.so -lonion_handlers -lonion_static -lpam -lgnutls -lgcrypt -lpthread -lrt -Wl,-rpath,$PWD/../onion/build/src/onion/libonion.so -Wl,-path,$PWD/../onion/build/src/onion/handlers/libonion_handlers.so
This gives a few errors:
/usr/bin/ld: unrecognized option '-path'
/usr/bin/ld: use the --help option for usage information
collect2: error: ld returned 1 exit status
Note
: Only an a
executable file is generated. There isn't any a.out
from onion.
You mistyped rpath
as path
on the second time.
The 'r' from rpath
means "runtime".
-rpath=dir
Add a directory to the runtime library search path. (...)
from onion.
Thanks very much for your reply. Still no luck! :(
[gideon@gideon-fedora c_stuff]$ gcc -o a a.c -L../onion/build/src/onion/libonion.so -L../onion/build/src/onion/handlers/libonion_handlers.so -lonion_handlers -lonion_static -lpam -lgnutls -lgcrypt -lpthread -lrt -Wl,-rpath,$PWD/../onion/build/src/onion/libonion.so -Wl,-rpath,$PWD/../onion/build/src/onion/handlers/libonion_handlers.so
[gideon@gideon-fedora c_stuff]$ ./a
./a: error while loading shared libraries: libonion_handlers.so: cannot open shared object file: No such file or directory
I checked that libonion_handlers.so1 in the direction pointed to exists. Also tried without the
-L` option.
from onion.
I mistakenly copied and pasted the path but forgot to remove the filename. -rpath expects a directory, not a path. So the correct is:
gcc -o a a.c -L../onion/build/src/onion/ -L../onion/build/src/onion/handlers/ -lonion_handlers -lonion_static -lpam -lgnutls -lgcrypt -lpthread -lrt -Wl,-rpath,$PWD/../onion/build/src/onion/ -Wl,-path,$PWD/../onion/build/src/onion/handlers/
Also, on my gcc version (which is 4.8.2), you can replace the whole -Lpath/to/lib -Wl,-rpath,path/to/lib -lmylib
with just path/to/lib/libmylib.so
.
from onion.
To check if your path is correcly set you can check with ldd:
dmoreno@zenbook:/src/gideon$ export/src/gideon$ ldd ./a
LD_LIBRARY_PATH=../onion/build/src/onion/:../onion/build/src/onion/handlers/
dmoreno@zenbook:
linux-vdso.so.1 => (0x00007fffb87fe000)
- libonion_handlers.so =>
../onion/build/src/onion/handlers/libonion_handlers.so (0x00007fec98edb000)*
libpam.so.0 => /lib64/libpam.so.0 (0x0000003f28c00000)
libgnutls.so.28 => /lib64/libgnutls.so.28 (0x0000003f29a00000)
libgcrypt.so.11 => /lib64/libgcrypt.so.11 (0x0000003de3000000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003dcd000000)
librt.so.1 => /lib64/librt.so.1 (0x0000003dcdc00000)
libc.so.6 => /lib64/libc.so.6 (0x0000003dcc800000)
libpam_misc.so.0 => /lib64/libpam_misc.so.0 (0x0000003f27c00000)
libxml2.so.2 => /lib64/libxml2.so.2 (0x0000003dd3800000) - libonion.so => /home/dmoreno/src/onion/build/src/onion/libonion.so
(0x00007fec98c92000)*
libaudit.so.1 => /lib64/libaudit.so.1 (0x0000003f28800000)
libdl.so.2 => /lib64/libdl.so.2 (0x0000003dccc00000)
libz.so.1 => /lib64/libz.so.1 (0x0000003dcd400000)
libp11-kit.so.0 => /lib64/libp11-kit.so.0 (0x0000003f29200000)
libtasn1.so.6 => /lib64/libtasn1.so.6 (0x0000003dea800000)
libnettle.so.4 => /lib64/libnettle.so.4 (0x0000003f29600000)
libhogweed.so.2 => /lib64/libhogweed.so.2 (0x0000003f29e00000)
libgmp.so.10 => /lib64/libgmp.so.10 (0x0000003de7000000)
libgpg-error.so.0 => /lib64/libgpg-error.so.0 (0x0000003ddfc00000)
/lib64/ld-linux-x86-64.so.2 (0x0000003dcc000000)
liblzma.so.5 => /lib64/liblzma.so.5 (0x0000003dd1800000)
libm.so.6 => /lib64/libm.so.6 (0x0000003dcd800000)
libffi.so.6 => /lib64/libffi.so.6 (0x0000003dcf400000)
Did using LD_LIBRARY_PATH worked?
2014/1/22 AndrΓ© Puel [email protected]
I mistakenly copied and pasted the path but forgot to remove the filename.
-rpath expects a directory, not a path. So the correct is:gcc -o a a.c -L../onion/build/src/onion/ -L../onion/build/src/onion/handlers/ -lonion_handlers -lonion_static -lpam -lgnutls -lgcrypt -lpthread -lrt -Wl,-rpath,$PWD/../onion/build/src/onion/ -Wl,-path,$PWD/../onion/build/src/onion/handlers/
Also, on my gcc version (which is 4.8.2), you can replace the whole -Lpath/to/lib
-Wl,-rpath,path/to/lib -lmylib with just path/to/lib/libmylib.so.β
Reply to this email directly or view it on GitHubhttps://github.com//issues/53#issuecomment-33025068
.
David Moreno Montero
[email protected]
+34 658 18 77 17
+44 74 23 21 01 57
http://www.coralbits.com/
http://www.coralbits.com
from onion.
A comment sent by email seems to be lost (maybe it will appear later), just in case I copy it again:
It is looking for system wide installed libonion_handlers.so, and I guess you have it not installed (yet). Try adding a LD_LIBRARY_PATH envvar:
$ export LD_LIBRARY_PATH=../onion/build/src/onion/:../onion/build/src/onion/handlers/
$ ./a
Another option is to compile all static:
$ gcc -o a a.c -L../onion/build/src/onion/ -L../onion/build/src/onion/handlers/ -lonion_handlers_static -lonion_static -lpam -lgnutls -lgcrypt -lpthread -lrt
Regards,
David.
from onion.
It is looking for system wide installed libonion_handlers.so, and I guess
you have it not installed (yet). Try adding a LD_LIBRARY_PATH envvar:
$ export
LD_LIBRARY_PATH=../onion/build/src/onion/:../onion/build/src/onion/handlers/
$ ./a
Another option is to compile all static:
$ gcc -o a a.c -L../onion/build/src/onion/
-L../onion/build/src/onion/handlers/ -lonion_handlers_static
-lonion_static -lpam -lgnutls -lgcrypt -lpthread -lrt
Regards,
David.
2014/1/22 Gideon Israel Dsouza [email protected]
So I recompiled onion:
-- libxml2 found. WebDAV support is compiled in.
-- pam found. PAM support is compiled in in handlers.
-- libpng found. png support is compiled in at extras.But now this happens:
[gideon@gideon-fedora c_stuff]$ gcc -o a a.c -L../onion/build/src/onion/libonion.so -L../onion/build/src/onion/handlers/libonion_handlers.so -lonion_handlers -lonion_static -lpam -lgnutls -lgcrypt -lpthread -lrt
[gideon@gideon-fedora c_stuff]$ ./a
./a: error while loading shared libraries: libonion_handlers.so: cannot open shared object file: No such file or directoryAny ideas?
β
Reply to this email directly or view it on GitHubhttps://github.com//issues/53#issuecomment-33020869
.
David Moreno Montero
[email protected]
+34 658 18 77 17
+44 74 23 21 01 57
http://www.coralbits.com/
http://www.coralbits.com
from onion.
Ah finally got it working with @Andrepuel's last comment.
However, what address and port number does this code run on? How do I view it in a webbrowser?
#include <onion/onion.h>
#include <onion/handlers/exportlocal.h>
#include <onion/handlers/auth_pam.h>
int main(int argc, char **argv){
onion *o=onion_new(O_THREADED);
onion_set_certificate(o, O_SSL_CERTIFICATE_KEY, "cert.pem", "cert.key", O_SSL_NONE);
onion_set_root_handler(o, onion_handler_auth_pam("Onion Example", "login", onion_handler_export_local_new(".")));
onion_listen(o);
onion_free(o);
return 0;
}
from onion.
It listens at http://localhost:8080 by default.
2014/1/22 Gideon Israel Dsouza [email protected]
Ah finally got it working with @Andrepuel https://github.com/Andrepuel's
last comment.However, what address and port number does this code run on? How do I view
it in a webbrowser?#include <onion/onion.h>
#include <onion/handlers/exportlocal.h>
#include <onion/handlers/auth_pam.h>
int main(int argc, char **argv){
onion *o=onion_new(O_THREADED);
onion_set_certificate(o, O_SSL_CERTIFICATE_KEY, "cert.pem", "cert.key", O_SSL_NONE);
onion_set_root_handler(o, onion_handler_auth_pam("Onion Example", "login", onion_handler_export_local_new(".")));
onion_listen(o);
onion_free(o);
return 0;
}β
Reply to this email directly or view it on GitHubhttps://github.com//issues/53#issuecomment-33056416
.
David Moreno Montero
[email protected]
+34 658 18 77 17
+44 74 23 21 01 57
http://www.coralbits.com/
http://www.coralbits.com
from onion.
Excellent! It worked π thanks very much for your help.
I'm assuming I can use onion to run a simple data driven site right ? It should be pretty performant right?
from onion.
Glad to hear it!
Yes to both, but as always, you better benchmark and test if it suits your requirements.
If you find any other problem, please ask so we can make a better onion. :)
from onion.
Related Issues (20)
- Onion examples - websockets: close websocket?
- autologin
- [info] Looking for a html GUI on c HOT 2
- Old CMake version HOT 1
- WebSockets SEND limit? HOT 1
- Are websockets blocked? HOT 6
- How to build libonion with DWARF debug information and optimizations? HOT 1
- Wrong return value of 'onion_websocket_write'
- unsafe fileserver.c example (about Unix signals)
- Any plans on supporting "SameSite" cookie? HOT 2
- can not get post data by example "post" HOT 4
- onion malloc(): unsorted double linked list corrupted HOT 1
- Wiki pages edit access
- Cannot authenticate on Centos7 with PAM enabled
- Null pointer dereferences
- Randomly generated UUID can contain `'\0'` HOT 2
- Runing in a non Systemd system HOT 1
- Error creating connection after 1024 requests HOT 1
- Gets stuck at gnutls_handshake()
- Does chunked encoding work?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from onion.