Jump to content

[Resolvido] Erro ao importar bibliotecas externas


Recommended Posts

Posted

Boas,

Iniciei á pouco um projecto com OpenCV, mas instalei direito, inseri o caminho para a pasta bin nas variaveis de sistema e pensei que ia dar tudo direito... Já importei no projecto os includes que uso e isso fez-me desaparecer uns erros que apareciam, mas este continua.. O que me falta importar?

Erro1:

error LNK2001: unresolved external symbol _cvCreateImage teste.obj

Erro2:

fatal error LNK1120: 1 unresolved externals

Deixo o código mas acho que não é por isso que dá o erro:

#include "stdafx.h"
#include <cv.h>
#include <cvaux.h>
#include <highgui.h>
#include <math.h>
#include <iostream>

//Include para o getSystemMetrics para depois centrar a janela
#define COMPILE_MULTIMON_STUBS
#include "multimon.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//-------------------------------------------------------------

using namespace std;

int main(int argc, char** argv)
{

int XXX, YYY;    
int height = 620;
int width = 440;

CvCapture* img = cvCaptureFromCAM(0);

    IplImage* im = cvQueryFrame(img);

    cvNamedWindow("Imagem", 1);
    cvShowImage("Imagem", im);
    XXX = (GetSystemMetrics(SM_CXVIRTUALSCREEN) - im->width)/2;
    YYY = (GetSystemMetrics(SM_CYVIRTUALSCREEN) - im->height) /2;
    cvMoveWindow("Imagem", XXX, YYY);
    cvWaitKey();
    cvReleaseCapture(&img);


CvPoint pt = cvPoint( height/4, width/2 );
IplImage* hw = cvCreateImage(cvSize(height, width), 8, 3);
cvSet(hw,cvScalar(0,0,0));
CvFont font;
cvInitFont( &font, CV_FONT_HERSHEY_COMPLEX,1.0, 1.0, 0, 1, CV_AA);
cvPutText(hw, "Bem-Vindo", pt, &font, CV_RGB(150, 0, 150) );
cvNamedWindow("Titulo", 0);
cvShowImage("Titulo", hw);
cvWaitKey(0);  

exit(0);
return 0;
}
Posted

suponho que não seja um problema de linkagem, visto que a função cvCreateImage surge após para ai 20 chamadas à API que estás a usar, mas só para ter a certeza, estás a linkar as libs/dlls não estás?

Posted

Sou novo em c++ por isso posso dizer asneiras, mas no visual studio 2005, tem as opções do projecto e lá em 1º lugar fui a c/c++, depois additional include directories e inseri as pastas onde cria ir buscar os includes que adiciona-se...

Quanto ás Libs, adicionei ás variáveis de sistema, que é o que faço em java e á partida funciona, mas aqui não funcionou... Será que tenho de adicionar noutro sitio do projecto?

Posted

no visual c++, vais a Configuration properties -> Linker -> Input -> Addional dependencies, e lá metes as libs que queres

Muito Obrigado pela ajuda, funcionou bem... Não sabia que tinha uma parte só para adicionar dependências...

Obrigado  🙂

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.