Probleme de linkage avec mingw

Résolu/Fermé
momo_oca - 15 févr. 2013 à 14:38
mamiemando Messages postés 33088 Date d'inscription jeudi 12 mai 2005 Statut Modérateur Dernière intervention 30 avril 2024 - 8 mars 2013 à 00:45
Bonjour,

J'ai un soucis de linkage mingw sous codeblocks.
Quelqu'un peut 'il m'aider ?

code :
/*
This example describes the FIRST STEPS of handling Baumer-GAPI SDK.
The given source code applies to handling one system, one camera and one image.
Please see "Baumer-GAPI SDK Programmer's Guide" chapter 4.
*/
#include <bgapi/bgapi.hpp>
#include <bgapi/bgapidef.hpp>
#include <bgapi/bgapiresult.h>
#include <stdlib.h>
#include <stdio.h>
//#include "bgapi.hpp"


#include <conio.h>


int main()
{
//DECLARATION
//===========

//Variables for first picture
int system_count=0; ;
int camera_count = 0;
BGAPI::System * pSystem = NULL;
BGAPI::Camera * pCamera = NULL;
BGAPI::Image * pImage = NULL;

BGAPI_RESULT res =BGAPI_RESULT_FAIL;
//COUNTING AVAILABLE SYSTEMS

res=BGAPI::countSystems(&system_count);
//res =system_count;
if( res != BGAPI_RESULT_OK )
{
printf("Count system object errorcode: %d system_count: %d\n", res, system_count);
return 0;
}
printf("4.1.2. Detected systems: %d\n", system_count);
}

ERREUR AFFICHER APRES COMPILATION

SDK 1.7\Components\Dev\C_C++\Lib\x86\bgapi.lib"
obj\Debug\main.o: In function 'ZN5BGAPI12countSystemsEPi':
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/../../../../include/bgapi/bgapi.hpp:120: undefined reference to '_imp__BGAPI_countSystems'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings (0 minutes, 0 seconds)
A voir également:

1 réponse

mamiemando Messages postés 33088 Date d'inscription jeudi 12 mai 2005 Statut Modérateur Dernière intervention 30 avril 2024 7 751
15 févr. 2013 à 21:12
Déjà en terme de code, la fonction main ne retourne pas systématiquement un int. Normalement cette fonction devrait se finir par un "return 0;".

Ensuite ton erreur ne vient pas du code puisque c'est une erreur de linkage et non une erreur de compilation. C'est simplement que dans ton makefile ou l'outil qui te sert à compiler, il faut référencer que tu lies ton programme à une librairie (sous linux : il faut indiquer avec quel ".so" ou quel ".a" tu linkes ; sous windows : il faut indiquer avec quelle ".dll" ou quel ".lib" tu linkes ton programme).

Exemple : si tu dois linker avec /home/toto/libtoto.so la ligne de compilation du fichier qui contient la fonction main est du genre :

g++ -Wall -L/home/toto -Wl,-R /home/toto main.cpp -ltoto


Bonne chance
1
merci c'est résolu, j
0
mamiemando Messages postés 33088 Date d'inscription jeudi 12 mai 2005 Statut Modérateur Dernière intervention 30 avril 2024 7 751
8 mars 2013 à 00:45
Parfait bonne continuation !
0