Author Topic: Info about lib finder  (Read 13395 times)

Max

  • Guest
Info about lib finder
« on: October 10, 2006, 10:06:45 am »
Dear all,
I observed a new plugin in the latest nightly build (3050 Windows XP SP2), library finder.

I tried it. Adding several dir in which .lib .a and .dll are present (I do have libs in those dir), with and without
an open project/workspace but the answer is always the same

"Didn't find any library"

Why? Is the pluging not working? (under dev) Am I using it in a wrong way? Which is its aim?

Thanks for the info.


Max


Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Info about lib finder
« Reply #1 on: October 10, 2006, 10:27:45 am »
Why? Is the pluging not working? (under dev) Am I using it in a wrong way? Which is its aim?
You didn't read the readme.txt, did you ?! ;-)
lib_finder only "knows" libraries when they are defined in a configuration (XML based) file. Of course no tool can know what compiler/linker options to set only from the fact "somewhere in that path exists a library". Please consult the readme.txt file in the lib_finder folder and the provided template (demonstration) files under [CodeBlocks]\share\CodeBlocks\lib_finder. Anyone who wants to provide additional templates - step forward!
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: Info about lib finder
« Reply #2 on: October 10, 2006, 10:29:30 am »
same for me ...

i was somewhat surprised, that the directory which i selected for searching
was removed immedeately from the list - is this intended behaviour ?

could someone please give an explanation how to use this plugin correctly ?

thanks, tiwag

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Info about lib finder
« Reply #3 on: October 10, 2006, 11:12:47 am »
Ok, here comes the content from the readme.txt file (as I have seen it's not in the nightly?!):

This Code::Blocks plugin was created to automatically find libraries installed in system. Each library is represented as global variable. If this global variable is configured by this plugin, all necessary steps to use such library is to:
- add $(#GLOBAL_VAR_NAME.include) in include directories
- add $(#GLOBAL_VAR_NAME.lib) in lib include directories
- add $(#GLOBAL_VAR_NAME.obj) in lib and resoure compiler directories
- add $(#GLOBAL_VAR_NAME.cflags) in other compiler options
- add $(#GLOBAL_VAR_NAME.lflags) in other linker options
(where GLOBAL_VAR_NAME should be changed to variable associated with given library, f.ex. WX will be used for wxWidgets, cb for Code::Blocks SDK. There's no rule describing how these global variables are named. But it should be short and easy to guess ;) These variables define all necessary directories and libraries needed during linkage.
WARNING: Because C::B allow only one directory for include / lib / obj paths, LibFinder will try to simulate others by adding them to LFLAGS and CFLAGS.
Libraries are configured in xml files (see lib_finder/README.txt for more details). LibFinder will search for these files in $(CB_DIR)/share/CodeBlocks/lib_finder. There are 3 libraries currently supported - wxWidgets (only wx 2.6 monolithic dll version), C::B sdk and OpenGL Framework.

In the folder with the XML defintion files is another readme.txt - here it goes:

This folder contains configuration files for libraries. Configurations are stored in XML format and must have .xml extension. The main skeleton of library configuration is as follows:

Code
<library name="Library Name" global_var="Global Var Name">
    <!--... Global configuration here ...-->
    <config>
        <!--... Library configurtion 1 ...-->
    </config>

    <config new_name="Changed library name">
        <!--... Library configurtion 2 ...-->
    </config>

    <!--... more configurations here ...-->
</library>

LibFinder assumes that each library may have different number of configurations (static library / dll / debug version etc. ), each of these configurations is set inside <config> </config> node. It will inherit all global settings defined outsidee these blocks. If there's no special configuration, LibFinder will use global settings as main configuration.

Configurable options are described below.
* File option : file option is used to to notify that library must have specified file. File names are relative to base library directory. There's no need to check all files included with library. But given list of files must not be ambiguous. Here's example of file option from wxWidgets library:
Code
    <file name="include/wx/wx.h"/>
    <file name="include/wx/wxprec.h"/>
* Path option : path option is used to add one of paths for library configuration. Like in global vars, there are three types of paths: include, lib, obj. These paths should be global, what can be done easily by using variables (it will be described later). Global Variable allow only one path to be defined but LibFinder tries to set additional directories through CFLAGS and LFLAGS. Paths can be defined with following tags:
Code
    <path include="include path"/>
    <path lib="lib path"/>
    <path obj="obj path"/>
* Flags option : flags option can be used to set compiler / linker flags (options). Good example is to set automatically linked librarues with LFLAGS and required dedfines with CFLAGS. Tag describing flags can be defined like in following forms (example from wxWidgets configuration):
Code
    <flags cflags="-DHAVE_W32API_H -D__WXMSW__ -DWXUSINGDLL"/>
    <flags lflags="-lwxmsw26"/>
* Variables : LibFinder allow to use variables what gives more flexibility. In order to use variable, You can use $(VARIABLE_NAME) anywhere in path, flags options and in library name. If variable named VARIABLE_NAME is declared, it will be replace by corresponding value. There's one variable always defined: $(BASE_DIR) and it contains global path to library root folder (paths of required files are relative to this base path). And it should be always used when declaring paths for this library, like:
Code
    <path include="$(BASE_DIR)/include"/>
Additional variables may be produced from names of directories in required files. If instead of directory name there is *$(VARIABLE_NAME), it does mean that any directory here will match and that variable named VARIABLE_NAME wil be set to this directory name. F.ex. :
Code
        <file name="lib/*$(CONFIG_NAME)/msw/wx/setup.h"/>
will set variable CONFIG_NAME with names of all directories inside lib, containing msw/wx/setup.h. (OF course, this path will be used when other file requirements are met). If variable is declared in more than one path, is must be same in all paths, otherwise, this will be threated like file name mismatch.

Anyway: Please notice that this plugin is still experimental. There are knows bugs (e.g. libs in root-folders are not recognised - thus, C:\wxWidgets is not found, but C:\Devel\wxWidgets) and this plugin has been added mainly to take it under source control and because the code was nearly lost. As with all contrib plugins: Use it at your own risk but any help with development is really welcome.

With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Info about lib finder
« Reply #4 on: October 10, 2006, 11:20:36 am »
could someone please give an explanation how to use this plugin correctly ?
What happens:
1.) Select the directories to search for libraries (that are defined in the XML config files, e.g. wxWidgets)
2.) Let lib_finder search the folders. Once the libs are found, configurations are offered to choose from (e.g. for wxWidgets the Unicode, non-Unicode...) -> choose one
3.) lib_finder will create global variables and fill their content accordingly.
4.) Create a new project and make use of the global vars (e.g. "WX") that have been setup.
"Unfortunately" this works for me - so currently I don't know what happens in your case - could you give me a step-by-step explanation to reproduce?
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: Info about lib finder
« Reply #5 on: October 10, 2006, 11:40:15 am »
..."Unfortunately" this works for me - so currently I don't know what happens in your case - could you give me a step-by-step explanation to reproduce?
With regards, Morten.

sorry, no i can't
now i do understand how it should work - i decide not to use it, thanks.

i don't see any effort with this plugin, i already know which libs i've installed.


what i do expect from a "lib finder" plugin, is to search all libs for exported symbols
for some unrefernced externals in case of a linker error and present me the name of
the libs, which are exporting these symbols.

brgds
tiwag

Max

  • Guest
Re: Info about lib finder
« Reply #6 on: October 10, 2006, 11:57:48 am »
sorry, no i can't
now i do understand how it should work - i decide not to use it, thanks.

me too...  :D

I need to look for a lib only when I got unreferenced symbols because I forgot to add it. Every programmer knows which libs are installed in his programming environment... well may be not all programmers ... :D

Max

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Info about lib finder
« Reply #7 on: October 10, 2006, 01:28:55 pm »
what i do expect from a "lib finder" plugin, is to search all libs for exported symbols
for some unrefernced externals in case of a linker error and present me the name of
the libs, which are exporting these symbols.
Ok, got the point. So there is a misunderstanding. This plugin was focussing on new users to C::B to enable them to easily setup global variables - hoping to make this easier and let experts provide the knowledge about libs and their required configuration. Using gcv's in the end may lead to a more structured "C::B project design". Now there are the wizards which enable this, too but in a different ("hard-coded") way. So this is just another option.

What you expect is (IMHO) for a different developer level. I once did this using then "nm" tool and a perl script. nm was parsing all libs and piped interesing content in a text file. Then the perl script did the rest (looking for the export...). But: From my experience this cannot be automated: You will receive a lot of same exports from different libs or even the same libs but in different version (version number and e.g. debug/release ansi/unicode version etc...) So what lib to add is the question. To decide this you need to have at least *some* more inside knowledge. Sure - there could be a plugin that offers all candidate libs, but this is very platform and compiler specific and you'll need the right tools...

Anyway: This could be done (I'm thinking of a wrapper to my nm - perl approach)... but I'd say publishing this will lead to a lot more problems then it solves because "newbies" will certainly pick the wrong lib... that's murphys law. ;-)

With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

takeshimiya

  • Guest
Re: Info about lib finder
« Reply #8 on: October 10, 2006, 01:44:59 pm »
On a side note, a well established standard that does the same, already exists and is being used in most Linux libraries.
It's called pkg-config and you can find more info here: http://pkgconfig.freedesktop.org/

Once upon a time, I was making a C::B plugin called pkg-config-manager for rapid editing and viewing of pkg-config files:


Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Info about lib finder
« Reply #9 on: October 10, 2006, 01:58:05 pm »
Once upon a time, I was making a C::B plugin called pkg-config-manager for rapid editing and viewing of pkg-config files:
See: Another plugin that got lost on the way... ;-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: Info about lib finder
« Reply #10 on: October 11, 2006, 12:39:32 am »
Wow, someone digged out my old plugin.
But I must confess to one thing: One of reasons I've created this plugin for was to somehow force C::B team to create something like Library database inside C::B.
Idea is easy: inside project optinos you don't have to set lot's of includes, lot's of libs, defines etc. You just select libraries to be used from list (and maybe set some basic options) and it works (all configuration is known by C::B inside Library database and Libfinder automatically searches for them and adds into database, o) and use standard compile options to configure project, not libraries. It would even make all projects cross platform (IDE would know how to include library inside project so no need to put it into cbp file). And automatically adding library into cbp file (something that was also discussed in this topic) could be done really easy with such system (just find what #include <> are used and find what library uses it, register and done).
Unfortunately this feature could not be created as plugin for some reasons (it does affect build process) or I don't know how this could be done easily.

Ok, few words about library finder:
Last time I've tested library finder plugin (wow, something like year ago) C::B changed some things inside build process and some problems occured. I've found out that extra includes and libraries can not be added through CXX flags, and since C::B does not support multiple include dirs this plugin may be useless in many cases. (F.ex. when using wxwidgets, you have to put multiple include dirs into cbp files just like in case of standard configuration so why to use lib finder it anyway). I think that this plugin will still have to wait :(

Offline Game_Ender

  • Lives here!
  • ****
  • Posts: 551
Re: Info about lib finder
« Reply #11 on: October 11, 2006, 02:44:46 am »
Sounds  like Takeshi Miya's pkg-config plugin.  It already maintains the database for you.
« Last Edit: October 11, 2006, 02:46:26 am by Game_Ender »

takeshimiya

  • Guest
Re: Info about lib finder
« Reply #12 on: October 11, 2006, 07:03:15 am »
I want to note that the plugin I was making was nice but not essencial, since you can already use pkg-config, and edit the .pc files by hand.

For those in Windows, pkg-config already compiled can be obtained here:
http://www.gimp.org/~tml/gimp/win32/pkg-config-0.20.zip
http://www.gimp.org/~tml/gimp/win32/libiconv-1.9.1.bin.woe32.zip
http://www.gimp.org/~tml/gimp/win32/gettext-0.14.5.zip
ftp://ftp.gtk.org/pub/glib/2.12/win32/glib-2.12.1.zip

I could create instructions of how to use it if anyone is interested, altrough it's very easy.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Info about lib finder
« Reply #13 on: October 11, 2006, 08:41:38 am »
Wow, someone digged out my old plugin.
That was me. :oops:
In fact I can't remember the source were I had found it but I knew it must have been done by Thomas and/or you. Anyway: I've "maintained" it during the time because at work I found it to be useful. I don't understand why you are saying the the WX setup will not work, because it actually works...?1 (Maybe I have something pre-configured that makes it work?!).
Anyway: I had a chat with Thomas and I think it's a nice work anyway... maybe not complete but I wouldn't keep it away from public. I'm not sure if it's worth distributing with C::B but definitley for "reading" as it has nice aspects of "what can be done" and for further development.
With regards, Morten.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: Info about lib finder
« Reply #14 on: October 11, 2006, 03:43:12 pm »
...From my experience this cannot be automated: You will receive a lot of same exports from different libs or even the same libs but in different version (version number and e.g. debug/release ansi/unicode version etc...) So what lib to add is the question. ...
that's exactly the point,

i had some troubles because an imported dev-cpp project seemed to be compiling and linking ok, but didn't work as expected.

the reason was, that the dev-cpp project added (i guess by default) a long long long list of (unneccessary) libs to the linker,
and it happened, that a specific function was exported from more than one library and my app didn't work as expected,
because the wrong lib was choosen by the linker.

my conclusion: it is bad behaviour to add all possibe libs - it is good behaviour to add only these libs which are actually needed.
with c++ name-mangling the problem isn't there, but with C function names it can happen ...

sometimes it is necessary to look somewhat deeper on what's happening behind the scene  :lol:

brgds, tiwag

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: Info about lib finder
« Reply #15 on: October 11, 2006, 05:53:21 pm »
Sounds  like Takeshi Miya's pkg-config plugin.  It already maintains the database for you.

But will it work with compilers other than gcc (it seems that many people use VCC or digital mars with C::B)?

I don't understand why you are saying the the WX setup will not work, because it actually works...?1 (Maybe I have something pre-configured that makes it work?!).

Yop, it will work. I've made configuration compatible with project configuration used for WX long time ago. But it won't work when you want to set-up additional include dirs through CXXFLAGS (that's where LibFinder stores extra includes using -I flag). So using wx in project requires you to know how to exactly configure it inside C::B project. You can not simply ise .include for include dir, .lib for lib dir ad .cflags .lflags for other thing to make project running. And I guess that people will require some other libraries usable in C::B - giving one unique configuration scheme for any library would be better than different schemes for different libraries.

BYO

takeshimiya

  • Guest
Re: Info about lib finder
« Reply #16 on: October 11, 2006, 06:16:34 pm »
Sounds  like Takeshi Miya's pkg-config plugin.  It already maintains the database for you.
But will it work with compilers other than gcc (it seems that many people use VCC or digital mars with C::B)?
pkg-config too :wink: