Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

891329 Posts in 33539 Topics- by 24776 Members - Latest Member: 1derboy

June 19, 2013, 01:44:30 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)[SOLVED FOR REAL] Linux library problems
Pages: [1] 2
Print
Author Topic: [SOLVED FOR REAL] Linux library problems  (Read 1217 times)
rivon
Level 10
*****



View Profile
« on: March 01, 2012, 01:50:48 PM »

Everything was working ok until suddenly I got "undefined references" to basic functions from "math.h" and pthreads and even NULL is said to be undefined.
When I build my own projects with Code::Blocks, everything is ok but when I try to build some files from school lessons using makefiles, it just throws errors. Something like a week ago, when building some other files from earlier lesson, it worked ok.

Here are the files:
http://www.mediafire.com/?4hijo2ysw4r9r40
http://www.mediafire.com/?y51rgdt0cnf8c48
but be warned, in some of them there are intentional mistakes. I don't care about them, I care about the undefined stuff.

By the way, all the headers are included and the libraries are linked (gcc -lm -lpthreads) so there isn't a problem in there.


I guess the harddrive/filesystem just got corrupted or something and I'm going to reinstall the system on the laptop.
« Last Edit: March 06, 2012, 01:53:19 PM by rivon » Logged
Revk
Level 0
**



View Profile WWW Email
« Reply #1 on: March 01, 2012, 03:43:40 PM »

The two compile and execute just fine on my system (Archlinux 3.1.5 x86_64).

Maybe you should try reinstalling the `glibc' package on your system using your package manager before reinstalling everything. Maybe gcc/gcc-libs too. I got glibc 2.15 and gcc/gcc-libs 4.6.2.
Logged
rivon
Level 10
*****



View Profile
« Reply #2 on: March 01, 2012, 04:05:59 PM »

I reinstalled all of the gcc, libc, libstdc++ and it still doesn't work.
Logged
Fallsburg
Level 10
*****


Fear the CircleCat


View Profile WWW
« Reply #3 on: March 01, 2012, 04:08:26 PM »

Environment variables, perhaps?
Can you find math.h on your system? I mean, if its there, then something is fucked up with your environment variables, I would say.
Logged

rivon
Level 10
*****



View Profile
« Reply #4 on: March 01, 2012, 04:46:45 PM »

It's right there in /usr/include... What env vars should I check?
Logged
Fallsburg
Level 10
*****


Fear the CircleCat


View Profile WWW
« Reply #5 on: March 01, 2012, 05:10:06 PM »

Well, I'm away from a linux box right now and a touch drunk, but off the top of my head PATH should do it.  LD_LIBRARY_PATH is another, but if you have the path to the include directory in your PATH you should be golden.
Logged

yesfish
Level 0
***


Yes Fish...


View Profile
« Reply #6 on: March 01, 2012, 06:26:46 PM »

haven't checked the source. But are you calling gcc instead of g++?
Logged
rivon
Level 10
*****



View Profile
« Reply #7 on: March 02, 2012, 05:40:05 AM »

GCC is called in those makefiles but AFAIK G++ should be able to compile it without problems.

Here is the "env" output:
Code:
rivon@glados:~$ env
SSH_AGENT_PID=1837
GLADE_PIXMAP_PATH=:
TERM=xterm
SHELL=/bin/bash
XDG_MENU_PREFIX=xfce-
XDG_SESSION_COOKIE=6a709450efbb84ecaf71328e0000000c-1330694840.561496-34024534
WINDOWID=56623109
GNOME_KEYRING_CONTROL=/tmp/keyring-5QutFM
GTK_MODULES=canberra-gtk-module:canberra-gtk-module
USER=rivon
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
GLADE_MODULE_PATH=:
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
SSH_AUTH_SOCK=/tmp/ssh-oJEBrJNN1792/agent.1792
SESSION_MANAGER=local/glados:@/tmp/.ICE-unix/1857,unix/glados:/tmp/.ICE-unix/1857
USERNAME=rivon
DEFAULTS_PATH=/usr/share/gconf/xubuntu.default.path
XDG_CONFIG_DIRS=/etc/xdg/xdg-xubuntu:/etc/xdg:/etc/xdg
PATH=/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
DESKTOP_SESSION=xubuntu
PWD=/home/rivon
GNOME_KEYRING_PID=1783
LANG=cs_CZ.UTF-8
MANDATORY_PATH=/usr/share/gconf/xubuntu.mandatory.path
GDMSESSION=xubuntu
SHLVL=1
HOME=/home/rivon
LOGNAME=rivon
XDG_DATA_DIRS=/usr/share/xubuntu:/usr/local/share/:/usr/share/:/usr/share
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-RI8pn7bG4v,guid=10b033a64879ff56fe52e232000002b3
LESSOPEN=| /usr/bin/lesspipe %s
DISPLAY=:0.0
GLADE_CATALOG_PATH=:
LIBGLADE_MODULE_PATH=:
LESSCLOSE=/usr/bin/lesspipe %s %s
COLORTERM=gnome-terminal
XAUTHORITY=/home/rivon/.Xauthority
_=/usr/bin/env
Logged
mewn
Level 0
*


View Profile
« Reply #8 on: March 02, 2012, 02:07:13 PM »

can you try to add /usr/lib to your path before compiling it again ?
   export PATH=$PATH:/usr/lib
if it fails, could you cut&paste the full output ?
Logged
Klaim
Level 10
*****



View Profile WWW
« Reply #9 on: March 02, 2012, 02:14:04 PM »

Did you upgrade gcc before getting the error?
Logged

http://www.klaimsden.net | Game : NetRush | Digital Story-Telling Technologies : Art Of Sequence
rivon
Level 10
*****



View Profile
« Reply #10 on: March 02, 2012, 04:05:37 PM »

Code:
rivon@glados:~/work/school/bi-osy/p02-examples$ make
gcc -Wall -pedantic  -lm -o prime1 prime1.c
/tmp/ccvLZ5yu.o: In function `isPrime':
prime1.c:(.text+0x32): undefined reference to `sqrt'
collect2: ld returned 1 exit status
make: *** [prime1] Error 1
Code:
rivon@glados:~/work/school/bi-osy/c02-examples$ make
gcc -Wall -pedantic  -lpthread -o matrix matrix.c
/tmp/ccoYfwaP.o: In function `thrFunc':
matrix.c:(.text+0x4a7): undefined reference to `pthread_barrier_wait'
matrix.c:(.text+0x4de): undefined reference to `pthread_barrier_wait'
/tmp/ccoYfwaP.o: In function `threadedPower':
matrix.c:(.text+0x595): undefined reference to `pthread_barrier_init'
matrix.c:(.text+0x5d4): undefined reference to `pthread_create'
matrix.c:(.text+0x623): undefined reference to `pthread_join'
matrix.c:(.text+0x645): undefined reference to `pthread_barrier_destroy'
collect2: ld returned 1 exit status
make: *** [matrix] Error 1

I don't know about the update as I don't really pay much attention when updating but it's possible.
Logged
Fallsburg
Level 10
*****


Fear the CircleCat


View Profile WWW
« Reply #11 on: March 02, 2012, 04:16:05 PM »

Try g++? I have had weird stuff in the where it wouldn't work with gcc but would work with g++.
I mean, according to GNU /usr/include should always be considered, no matter the other search path stuff, so I'm not seeing the problem on that front.
Logged

rivon
Level 10
*****



View Profile
« Reply #12 on: March 02, 2012, 04:54:26 PM »

I even tried adding /usr/lib, /usr/include, /usr/local/lib and /usr/local/include to search dirs but it didn't help. Will try g++ tomorrow but I'm most likely going to reinstall it anyway.
Logged
henzenmann
Level 0
**


View Profile
« Reply #13 on: March 03, 2012, 02:13:52 PM »

What version of GCC and binutils are you using? I was able to compile that code without problems with either GCC 3.4, 4.4 and 4.6 and binutils 2.20.1.

The order in which you specify objects (or source in your case) and libraries may be problematic - try putting all the "-l..." flags at the end of the command line.

Also try to separate compilation and linking, and see if that makes a difference:

Code:
gcc -Wall -pedantic -c prime1.c
gcc -o prime1 prime1.o -lm
Logged
rivon
Level 10
*****



View Profile
« Reply #14 on: March 03, 2012, 02:16:57 PM »

Whatever, I reinstalled it Wink
Logged
Pages: [1] 2
Print
Jump to:  

Theme orange-lt created by panic