Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Lib symbols could not be resolved(Using an external lib (ImageMagick), can't make the IDE understand the source)
Lib symbols could not be resolved [message #1821076] Wed, 05 February 2020 09:16 Go to next message
Leo Subirana is currently offline Leo SubiranaFriend
Messages: 2
Registered: February 2020
Junior Member
I'm trying to use Magick++ lib, code works as expcected but IDE does not

Issue:
IDE marks Symbol "Magick" could not be resolved
(Also other items from the same lib)

I can navigate to declaration of the lib header file, also it has no warning / error:
#include <Magick++.h>
And continue navigationg through all of it without issues or any warning on their files.
But on my cpp file, the lib Symbols are marked as errors.

Tryed to search about this kind of issues, but usually they are solved after adding the include to the header files witch is already done:
index.php/fa/37285/0/

Also tried to restart eclipse, reboot, refresh project.

The lib installation, compilation and run of sample demo works properly.
Sample:
index.php/fa/37286/0/


Now the info:
Eclipse IDE for C/C++ Developers
Version: 2019-09 R (4.13.0)
Build id: 20190917-1200

Eclipse C/C++ Development Tools
Version: 9.9.0.201909091956

Lib Installation made through this steps:
Sorry, can't post links due low amount of messages
//============================================================================
// Name        : MagickTest.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <Magick++.h>
#include <iostream>

using namespace std;
using namespace Magick; // <-- Symbol not found

int main(int argc,char **argv)
{
  InitializeMagick(*argv); // <-- Functionnot found

  Image image; // Not found ...
  try {
    // Read a file into image object
    image.read( "logo:" );

    // Crop the image to specified size (width, height, xOffset, yOffset)
    image.crop( Geometry(100,100, 100, 100) );

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


I was able to make eclipse to compile it properly with the following project properties:
Project properties -> C/C++ Build / Settings / Tool Settings (tab):
- GCC C++ Compiler / Includes:
Include path (-l):
/usr/local/include/ImageMagick-7

- GCC C++ Compiler / Miscelaneous
On Other flags, add:
`Magick++-config --cxxflags --cppflags` `Magick++-config --ldflags --libs`

Which creates an options convination of:
-I/usr/local/include/ImageMagick-7 -O0 -g3 -Wall -c -fmessage-length=0 `Magick++-config --cxxflags --cppflags` `Magick++-config --ldflags --libs`

- GCC C++ Linker/ Libraries:
Magick++-7.Q16HDRI
MagickWand-7.Q16HDRI
MagickCore-7.Q16HDRI

Could find the libs after searching them with:
find /usr -name "*Magick++*"

Also, i think this happened automatically:
Project properties -> C/C++ General / Preprocessor Include Paths, Macros, etc.
GNU C++:
CDT Managed Build Setting Entries has an entry to (not editable):
/usr/local/include/ImageMagick-7

Re: Lib symbols could not be resolved [message #1821438 is a reply to message #1821076] Thu, 13 February 2020 04:26 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
When referencing headers, you need to inform the compiler and also the Indexer.
Two different things.

You can tell the compiler via Eclipse only when Eclipse is generating the makefile.
That is, a Managed Build project.
Your project seems to be a Managed Build project.

You tell the Indexer with Project --> Properties --> C/C++ General --> Preprocessor Include Paths, Macros etc.
which only cares about headers and collects their paths through various providers.
One of the providers collects them from the Managed Build Settings.
It's not editable because its entries are generated by some scanner code and not the user.
When using the Managed Build Settings provider, the index will be rebuilt after a project build.

If it doesn't you can try rebuilding the index manually.
Project --> C/C++ Index --> Rebuild

I copied your code and got no errors.
But I had to do at least one build.
index.php/fa/37360/0/

A note on using Magick++-config.
In a Managed Build, compiles and links are separate steps.
So, you only need: `Magick++-config --cxxflags --cppflags` for compiles.
And, `Magick++-config --ldflags --libs` for the link.
Putting them together is OK but not really needed.


Re: Lib symbols could not be resolved [message #1821625 is a reply to message #1821438] Mon, 17 February 2020 16:48 Go to previous messageGo to next message
Helen Keller is currently offline Helen KellerFriend
Messages: 173
Registered: June 2019
Senior Member
Confused with terminology - again.
where are the library "includes" , or should they be called links ??
I though you specify source - header files - in complier - under plain "#include " or by other means, but not indexer.
Then you specify the library - in linker - which are really not includes but links and files.

Not really understand the INDEXER purpose. Just something one has to watch and let it finish doing whatever it does...
Re: Lib symbols could not be resolved [message #1821641 is a reply to message #1821625] Tue, 18 February 2020 06:20 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
The Indexer
https://help.eclipse.org/2019-12/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Fconcepts%2Fcdt_c_indexer.htm
It keeps track of code declarations to aid flagging possible errors and searching.

The errors shown by the OP are caused by the Indexer not knowing where the included headers can be found or the index not being updated.

The linker info is a side issue with using Magick++-config.
If you aren't using Magick++-config, it isn't important.

[Updated on: Tue, 18 February 2020 06:40]

Report message to a moderator

Re: Lib symbols could not be resolved [message #1821646 is a reply to message #1821641] Tue, 18 February 2020 07:44 Go to previous messageGo to next message
Leo Subirana is currently offline Leo SubiranaFriend
Messages: 2
Registered: February 2020
Junior Member
Yes, the main issue was indexer not indexing even after build or reboot.
I had to run it manually as David Vavra stated: Project --> C/C++ Index --> Rebuild, from then It worked fine.

Thank you very much.

As I had hard time making Magick++ work, I will just leave here some steps I followed in case anyone can benefit from that:

This is some good install tutorial:
https://imagemagick.org/script/install-source.php

You can find the installed lib on /usr/local/lib, at least given my current enviroment:
Debian 4.19.67-2+deb10u2

Furthermore, the linker lib names are the files in there without the "lib" at the start of the name.
Last but not least, to fully use Magick++, you will need "delegates", which are libraries for specific formats and/or tasks. Running:
$ convert -version
will give you info of the currently installed delegates:
Version: ImageMagick 7.0.9-21 Q16 x86_64 2020-02-18 https://imagemagick.org
Copyright: © 1999-2020 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP(4.5)
Delegates (built-in): jng jpeg png x zlib


A good way to find the ones you are looking for and to install them manually:
$ sudo apt -s build-dep imagemagick | grep -i png
Note the grep of file format I was looking support for. Then you will need to run the configure, make and make install again on the source.

Sorry for extra offtopic info but could not find all this together anywhere, so some people can benefit from it

[Updated on: Tue, 18 February 2020 13:15]

Report message to a moderator

Re: Lib symbols could not be resolved [message #1821679 is a reply to message #1821646] Tue, 18 February 2020 15:10 Go to previous message
Helen Keller is currently offline Helen KellerFriend
Messages: 173
Registered: June 2019
Senior Member
Don't be sorry for your post , sometime "the guardians" are too narrow-minded as far as post being in right pew.
If it makes any difference - your post t definitely helped me. Thanks.

As far as "indexer" goes - it is still mystery to me , even after reading the "spec".
As far as I can tell in does nothing for libraries.

For example It seems to be attempt to help keep track of changes in "source file" , but I still have to manually "save all" before "Build".
I have found that letting the IDE automatically "save before build" is unreliable and of course no feedback is given until "missing binaries" message is posted.
Next time I'll try "search for unresolved includes " .

Previous Topic:Trouble moving code from CodeBlocks to Eclipse
Next Topic:Multiple definitions between subfolders
Goto Forum:
  


Current Time: Sat Apr 20 01:56:59 GMT 2024

Powered by FUDForum. Page generated in 0.03069 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top