You are not logged in.
Hey guys, anyone feel like helping out a C nub? . I'm trying to get scons to link libonion correctly and I can't seem to figure out how to do this. Here's my code: https://github.com/saiko-chriskun/audiakon
Been sitting here for hours now heh. Any insight would be greatly appreciated!
[home page] -- [code / configs]
"Once you go Arch, you must remain there for life or else Allan will track you down and break you." -- Bregol
Offline
It would help to know what you have attempted and what error messeges you are getting.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
I've no clue of scons at all, so I might be mistaken, but I didn't find any kind of linking instruction in your build files. To me it looks like you are somehow assuming that the "Repository()" method would magically build libonion and link it into your program. How did you get this idea?! The documentation of "Repository()" doesn't even mention the term "linking". Actually, this method doesn't have anything to do, it apparently merely specifies additional directories to search for source or header files.
There is however a dedicated section about Linking with libraries. Basically, you need to specify the names of libraries to link against in the "Program()" call. In order to do so, you need to manually build libonion before.
Offline
@Trilby- just run 'scons'. It'll also output the standard gcc command it's trying to use to build it.
@lunar- Yeah I've read all the scons docs. idk is there something obvious I'm just not seeing? The libonion docs just seems to #include the header files, though (as seen here). I've simply copied that into my main.c.
EDIT: @lunar- I /can/ actually get it to build/link individual onion source files, but I would have to do that manually for every file and that just seems like the wrong way to go about things.
EDIT2: idk if it helps but it DOES find and compile the header files properly, it just doesn't match the function prototypes to their definitions.
Last edited by chris-kun (2012-04-20 17:23:55)
[home page] -- [code / configs]
"Once you go Arch, you must remain there for life or else Allan will track you down and break you." -- Bregol
Offline
[starlight] /tmp/audiakon > scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
gcc -o build/main.o -c -Ibuild -Isrc -Isubmodules/onion/src -Isubmodules/onion/build src/main.c
src/main.c:3:25: fatal error: onion/onion.h: No such file or directory
[starlight] /tmp/audiakon > ls submodules/onion
[starlight] /tmp/audiakon >
Looks like you simply don't have any onion/onion.h file in your repository. That would indeed be a problem.
But this isn't a linking problem, but rather a compiling one. Am I getting the same error as you are?
Offline
run: git submodule init && git submodule update
[home page] -- [code / configs]
"Once you go Arch, you must remain there for life or else Allan will track you down and break you." -- Bregol
Offline
Haha. Yes, sorry.
I managed to get it to build&link with the following src/SConscript:
env = Environment(
CPPPATH = ['.'],
LIBPATH=['../submodules/onion/src/onion'],
LIBS=['onion_static', 'pthread', 'gnutls', 'rt', 'gcrypt']
)
Export('env')
env.Program('../bin/audiakon', Glob('*.c'))
Repository('../submodules/onion')
I'll admit I've never used the Repository SCons function, but after reading the manpage, it doesn't seem to be what you want:
To scons, a repository is a copy of the source tree, from the top-level
directory on down, which may contain both source files and derived files
that can be used to build targets in the local source tree. The canonical
example would be an official source tree maintained by an integrator. If
the repository contains derived files, then the derived files should have
been built using scons, so that the repository contains the necessary sig‐
nature information to allow scons to figure out when it is appropriate to
use the repository copy of a derived file, instead of building one
locally.
Offline
hm that's weird. I copied that exact SConscript and I get:
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
gcc -o build/main.o -c -Ibuild -Isrc -Isubmodules/onion/src -Isubmodules/onion/build src/main.c
gcc -o bin/audiakon build/main.o -Lsubmodules/onion/src/onion -Lsubmodules/onion/submodules/onion/src/onion -lonion_static -lpthread -lgnutls -lrt -lgcrypt
ld: warning: directory not found for option '-Lsubmodules/onion/submodules/onion/src/onion'
ld: library not found for -lonion_static
collect2: ld returned 1 exit status
scons: *** [bin/audiakon] Error 1
scons: building terminated because of errors.
[home page] -- [code / configs]
"Once you go Arch, you must remain there for life or else Allan will track you down and break you." -- Bregol
Offline
I had to build the onion library myself before trying to build your audiakon. Since onion doesn't even use SCons, I don't think you can expect it to get built automatically with SCons. Unless you write your own SConscript for it, of course.
Offline
what's the command to get onion to build?
EDIT: ah I think I got it, "cmake -G "Unix Makefiles"
Last edited by chris-kun (2012-04-20 18:06:48)
[home page] -- [code / configs]
"Once you go Arch, you must remain there for life or else Allan will track you down and break you." -- Bregol
Offline
cd submodules/onion && cmake . && make
Last edited by Oxyd (2012-04-20 17:53:21)
Offline
hmm, cmake seemed to work fine, but when executing make:
Scanning dependencies of target onion
[ 1%] Building C object src/onion/CMakeFiles/onion.dir/onion.c.o
/Users/chris/code/audiakon/submodules/onion/src/onion/onion.c:151:20: error: malloc.h: No such file or directory
make[2]: *** [src/onion/CMakeFiles/onion.dir/onion.c.o] Error 1
make[1]: *** [src/onion/CMakeFiles/onion.dir/all] Error 2
make: *** [all] Error 2
[home page] -- [code / configs]
"Once you go Arch, you must remain there for life or else Allan will track you down and break you." -- Bregol
Offline
Wow. /usr/include/malloc.h comes with the glibc package which is in the base group. In other words, you should have it in your system. Try running make VERBOSE=1 -- it should output the commands it runs. Perhaps it's doing something weird?
Offline
hm yeah it might be a mac thing. My arch machine is back home but I'm actually at work right now so I was building on my mac hehe. Lemme ssh into my machine and see if it works there.
[home page] -- [code / configs]
"Once you go Arch, you must remain there for life or else Allan will track you down and break you." -- Bregol
Offline
That might well be it. You're going to have all necessary development packages installed on your Mac so that you have the headers and the libraries you want to use. (Starting with the C standard headers.) As I'm not a Mac user, I won't help you much in what exactly those are.
Offline
built successfully on arch . also got scons to work with:
env = Environment(CPPPATH = ['.', '../submodules/onion/src'], LIBPATH = ['../submodules/onion/src/onion'], LIBS = ['onion_static', 'pthread', 'gnutls', 'rt', 'gcrypt'])
Export('env')
env.Program('../bin/audiakon', Glob('*.c'))
Thanks a bunch for the help oxyd!
[home page] -- [code / configs]
"Once you go Arch, you must remain there for life or else Allan will track you down and break you." -- Bregol
Offline
@chris-kun: You'll need XCode to build on OS X. Btw, I'd consider linking really essential knowledge when working with C, and I still don't think that you really understood why you can successfully link against libonion now. In this case, I'd recommend you to leave Scons aside. Don't use a build system for know, but try to build your program by hand to understand how compilation of C programs really work.
Offline