• Willkommen im Linux Club - dem deutschsprachigen Supportforum für GNU/Linux. Registriere dich kostenlos, um alle Inhalte zu sehen und Fragen zu stellen.

[C] math wird nicht gelinkt

Tach,

leider wird die math lib nicht gelinkt, wenn ich in Eclipse ein Programm kompelieren möchte:

Code:
make -k all 
Building file: ../nn.c
Invoking: GCC C Compiler
gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"nn.d" -MT"nn.d" -o"nn.o" "../nn.c"
../nn.c:21: warning: return type defaults to ‘int’
../nn.c: In function ‘main’:
../nn.c:24: warning: missing braces around initializer
../nn.c:24: warning: (near initialization for ‘Input[0]’)
../nn.c:25: warning: missing braces around initializer
../nn.c:25: warning: (near initialization for ‘Target[0]’)
Finished building: ../nn.c
 
Building target: Small_net
Invoking: GCC C Linker
gcc  -o"Small_net"  ./nn.o   
./nn.o: In function `main':
/home/kai/.eclipse/Small_net/Debug/../nn.c:61: undefined reference to `exp'
collect2: ld returned 1 exit status
make: *** [Small_net] Fehler 1
make: Das Target »all« wurde wegen Fehlern nicht aktualisiert.
Build complete for project Small_net
Ich steh echt auf dem Schlauch! Die lib gehört doch zum ANSI Standard, oder? Ist das nicht in der glibc? Die stdio wird jedenfalls problemlos gelinkt. Muss ich vllt noch was im Eclipse konfigurieren?
Wo finde ich auf meinem System die libs eigentlich?

Specs:
Eclipse 3.2.2
CDT 3.1.2
openSuse 10.2

Freue mich sehr über Vorschläge (wie soll man schon ohne exp und Konsorten rechnen) und poste gerne weitere Informationen.

Gruß, Kai
 
ok, danke, das hat geholfen! :oops:
Hab unter Eclipse auch direkt das richtige Feld gefunden. In der Konsole wäre ich wahrscheinlich schneller drauf gekommen. Wundern tut mich nur, dass es für die anderen Standard Bibliotheken nicht notwendig ist (zumindest in Eclipse) sie explizit linken zu lassen.

Sehe ich das richtig: lm -> link math?

Gruß, Kai
 
Sehe ich das richtig: lm -> link math?
Durchaus nicht. 8)

Aus "man gcc":
-llibrary -l library
Search the library named library when linking ...
The linker searches a standard list of directories for the library, which is actually a file named liblibrary.a.
The linker then uses this file as if it had been specified precisely by name.
The directories searched include several standard system directories plus any that you specify with -L.
"-lm" entspricht also "-l /usr/lib/libm.a" :wink:.

C macht es einem manchmal unnötig schwer ...

Viele Grüße
 
Oben