[Solved][C++] Błąd linkowania w qtcreatorze
: 16 maja 2012, 16:47
Witam
Chce użyć biblioteki fann którą mam zainstalowaną. Mój kod programu:
Gdy kompiluje ręcznie to nie ma problemów wszystko się ładnie kompiluje, robię to tak:
W qt creatorze mój plik *.pro wyglada tak:
i wywala takie błędy:
No rozchodzi się o to -lm co potwierdza ten wpis na forum:
http://leenissen.dk/fann/forum/viewtopic.php?t=437
Co w takim razie robię źle?
Chce użyć biblioteki fann którą mam zainstalowaną. Mój kod programu:
Kod: Zaznacz cały
#include <fann.h>
int main(void)
{
const unsigned int num_input = 2;
const unsigned int num_output = 1;
const unsigned int num_layers = 3;
const unsigned int num_neurons_hidden = 3;
const float desired_error = (const float) 0.001;
const unsigned int max_epochs = 500000;
const unsigned int epochs_between_reports = 1000;
struct fann *ann = fann_create_standard(num_layers, num_input, num_neurons_hidden, num_output);
fann_set_activation_function_hidden(ann, FANN_SIGMOID_SYMMETRIC);
fann_set_activation_function_output(ann, FANN_SIGMOID_SYMMETRIC);
fann_train_on_file(ann, "and.data", max_epochs, epochs_between_reports, desired_error);
fann_save(ann, "and_float.net");
fann_destroy(ann);
return 0;
}
Kod: Zaznacz cały
g++ -lfann -lm main.c -o main
Kod: Zaznacz cały
TEMPLATE = app
CONFIG += console
CONFIG -= qt
SOURCES += main.c
LIBS += -lfann -lm
Kod: Zaznacz cały
16:36:28: Running steps for project fann_and...
16:36:28: Konfiguracja niezmieniona, krok qmake opuszczony.
16:36:28: Uruchamianie "/usr/bin/make" -w
make: Entering directory `/home/peer7/Programowanie/Qt4/fann_and/fann_and'
/usr/bin/qmake -spec /usr/share/qt/mkspecs/linux-g++ -o Makefile fann_and.pro
make: Leaving directory `/home/peer7/Programowanie/Qt4/fann_and/fann_and'
make: Entering directory `/home/peer7/Programowanie/Qt4/fann_and/fann_and'
g++ -Wl,-O1,--sort-common,--as-needed,-z,relro,--hash-style=gnu -Wl,-O1 -o fann_and main.o -lfann -lm
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../lib/libfann.so: undefined reference to `sinf'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../lib/libfann.so: undefined reference to `cosf'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../lib/libfann.so: undefined reference to `sin'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../lib/libfann.so: undefined reference to `exp'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../lib/libfann.so: undefined reference to `sqrtf'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../lib/libfann.so: undefined reference to `cos'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../lib/libfann.so: undefined reference to `log'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../lib/libfann.so: undefined reference to `pow'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../lib/libfann.so: undefined reference to `floor'
collect2: error: ld returned 1 exit status
make: Leaving directory `/home/peer7/Programowanie/Qt4/fann_and/fann_and'
make: *** [fann_and] Error 1
16:36:28: Proces "/usr/bin/make" zakończył się kodem wyjściowym 2.
Error while building/deploying project fann_and (target: Desktop)
When executing step 'Make'
http://leenissen.dk/fann/forum/viewtopic.php?t=437
Co w takim razie robię źle?