在Visual Studio代码中包括外部库C ++

我正在使用Visual Studio Code,用C ++编写,并且尝试添加一个外部库(确切地说是Magick ++。h)。即使我在lib文件夹中添加了.lib文件,在include文件夹中添加了标头,但错误仍然存​​在:

我用Google搜索了,发现了一个可能的解决方案,但我不知道如何实现。我想我会使用.L / -l,但在突击队行给我错误...

我的代码:

int main(){
char rutaImg[80]="C:\\programas\\tesseract\\input\\image.png";
InitializeMagick("C:\\Program Files\\ImageMagick-7.0.8-Q16");


  Image image;
  try { 
    // Read a file into image object 
    image.read( "C:\\programas\\tesseract\\inputENERO_ENERGIA_VIVA_ES0021000008414226EH-1.png" );

    // Crop the image to specified size (width,height,xOffset,yOffset)
    image.crop(Geometry(0,1947,3617,1789));

    // Write the image to a file 
    image.write( rutaImg);
  } 
  catch( Exception &error_ ) 
    {  
     cout<<"Caught exception: "<< error_.what()<<endl; 
      return 1; 
    } 
  return 0; 

}

错误日志:

C:\Users\VICTOR~1\AppData\Local\Temp\ccWYnNtq.o:imagenes.cpp:(.text+0x60): undefined reference to `Magick::InitializeMagick(char const*)'

C:\Users\VICTOR~1\AppData\Local\Temp\ccWYnNtq.o:imagenes.cpp:(.text+0x6d): undefined reference to `Magick::Image::Image()'

C:\Users\VICTOR~1\AppData\Local\Temp\ccWYnNtq.o:imagenes.cpp:(.text+0xa5): undefined reference to `Magick::Image::read(std::__cxx11::basic_string<char,std::char_traits<char>,std::allocator<char> > const&)'

C:\Users\VICTOR~1\AppData\Local\Temp\ccWYnNtq.o:imagenes.cpp:(.text+0xe5): undefined reference to `Magick::Geometry::Geometry(unsigned int,unsigned int,int,int)'

C:\Users\VICTOR~1\AppData\Local\Temp\ccWYnNtq.o:imagenes.cpp:(.text+0xfb): undefined reference to `Magick::Image::crop(Magick::Geometry const&)'

C:\Users\VICTOR~1\AppData\Local\Temp\ccWYnNtq.o:imagenes.cpp:(.text+0x108): undefined reference to `Magick::Geometry::~Geometry()'

C:\Users\VICTOR~1\AppData\Local\Temp\ccWYnNtq.o:imagenes.cpp:(.text+0x140): undefined reference to `Magick::Image::write(std::__cxx11::basic_string<char,std::allocator<char> > const&)'

C:\Users\VICTOR~1\AppData\Local\Temp\ccWYnNtq.o:imagenes.cpp:(.text+0x169): undefined reference to `Magick::Image::~Image()'

C:\Users\VICTOR~1\AppData\Local\Temp\ccWYnNtq.o:imagenes.cpp:(.text+0x1a2): undefined reference to `Magick::Geometry::~Geometry()'

C:\Users\VICTOR~1\AppData\Local\Temp\ccWYnNtq.o:imagenes.cpp:(.text+0x247): undefined reference to `Magick::Image::~Image()'
hanyudeng13105 回答:在Visual Studio代码中包括外部库C ++

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3124286.html

大家都在问