Problems (#1) - undefined reference to functions while compiling (#104) - Message List
I tried to build the wmdemo.c archive by gcc and it gives as error that can't find the functions related to cwiid.h, though it finds the library as it doesn't give any error reporting of it missing.
Happens the same when I try to build a little app similar to wmdemo that I made. Can't figure out where's the problem (I'm a bit new in linux).
gcc main.c /tmp/ccm0GiGS.o: In function `main': main.c:(.text+0x59): undefined reference to `cwiid_open' main.c:(.text+0x88): undefined reference to `cwiid_set_mesg_callback' main.c:(.text+0x1ad): undefined reference to `cwiid_get_state' main.c:(.text+0x1ec): undefined reference to `cwiid_close' /tmp/ccm0GiGS.o: In function `set_led_state': main.c:(.text+0x231): undefined reference to `cwiid_command' /tmp/ccm0GiGS.o: In function `set_rpt_mode': main.c:(.text+0x264): undefined reference to `cwiid_command' /tmp/ccm0GiGS.o: In function `print_report': main.c:(.text+0x366): undefined reference to `cwiid_enable' /tmp/ccm0GiGS.o: In function `cwiid_callback': main.c:(.text+0x44e): undefined reference to `cwiid_disable' collect2: ld va retornar l'estat de sortida 1
Thanks for reading.
-
Message #24411
Welcome to the wonderful world of Linux.
Build systems get complex pretty quickly, especially given the diversity of Linux and Linux-like systems and the desire for an app to work on all/most of them. Makefiles are often used to manage the build process, and even these get too complicated, so many apps use the GNU automake and autoconf systems.
In any case, the traditional way to build an application is to run, from the root of the tarball:
./configure make sudo make install
sudo, if you aren't familiar with it, allows trusted power users (often in a group called "wheel") to run commands as root. If you don't have sudo set up, you can just run the last command directly as root, and without the "sudo".
Incidentally, this sequence can be found in the README file in the root directory of the tarball - this is typical. You should get in the habit of reading README files before attempting to compile, install, execute, etc. - it will save you time, and prevent bashings from devs less patient than me.
dsmith09/26/08 14:02:40 (5 years ago)-
Message #24412
--Solved (dsmith, read edit)--
Yes, I know how to build and install applications downloaded in binary, I have also read the readme file in cwiid, installed all required libraries and have done everything written on the readme to install the cwiid library. It's after this point, when I try to build my little app that gcc gives me an error, as exposed in the first post.
I'm sorry if it bashes your time, I simply passed some hours attempting to find where the problem is and missed, because of this I decided to post this.
Well, I'll explain what I found... When building cwiid from binaries there's the dir named wmdemo where you can find wmdemo.c. When I compiled the libraries through ./configure make and make install in the same directory appeared an executable named wmdemo, which I opened from the terminal and worked well.
Then, to try something, I copied wmdemo.c to my desktop and tryed to compile it through gcc: gcc wmdemo.c when in the directory from the terminal. But it didn't success, in the terminal appeared an error similar to the one yet posted. There's no problem with not finding the library, as it doesn't report it, but seems like there weren't those functions...
For this I thought it could be something related to the makefile in the cwiid project... and maybe it could be solved with some kind of flags.
Thanks for reading and for helping.
EDIT: Ok, after talking to the teacher who is helping me with this project I could find out the solution to the problem by adding -lcwiid to the dependencies on the project. Thanks for replying, dsmith, and sorry if I caused any problem.
rocram1609/26/08 18:07:40 (5 years ago)-
Message #24413
You didn't cause any problem, I was just warning you that some people have little patience with support questions that they deem to be the result of ignorance of standard procedures, and will not respond politely. As you've explained, this is not the case with you.
You are correct about the Makefiles - their logic determines the build steps and flags used to compile/link/etc each of the source files. Some require options in addition to -lcwiid, and you can determine what these options are by examination of the Makefiles (the hard way), or examining the output of make (the easy way, if you know how to use grep).
The functions in question are stored in libcwiid.so (or a file that libcwiid.so links to), and the way to direct gcc to look for functions in that file is the -lcwiid function that your teacher suggested.
Good look with your project.
dsmith09/27/08 21:27:11 (5 years ago)
-
-
