Author Topic: extract some variables from a custom makefile ?  (Read 4939 times)

Offline rv2931

  • Multiple posting newcomer
  • *
  • Posts: 13
extract some variables from a custom makefile ?
« on: November 17, 2008, 09:32:52 am »
Hello

I have a little library that has its own Makefile.mingw or Makefile.win32
I don't use them because I don't really need them for the moment, and I don't really know how to use them and the utility of a makefile too for the moment.
I have just one problem with the library configuration. this is a pre-processing variable that define a variable that is tested all along the sources of the library for choosing the type of regexp used (PCRE, regcomp ...)
The variable that is tested is :
#ifdef USE_PCRE_REGEX
....
#else
...
#endif

this variable is apparently define by the lines in the Makefile.win32 :
PCRE_OPT = PCRE_CASELESS
...
REGEXP= /DUSE_PCRE_REGEX /DPCRE_OPT=$(PCRE_OPT)
...

If I don't want to use this Makefile, where and how can I put this few lines to have a USE_PCRE_REGEX defined during the compilation ?

Thanks

RV
« Last Edit: November 17, 2008, 09:49:35 am by rv2931 »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: extract some variables from a custom makefile ?
« Reply #1 on: November 17, 2008, 10:09:31 am »
You can add defines in the "Build options" of your project.

To get /DPCRE_CASELESS /DPCRE_OPT=PCRE_CASELESS, just add USE_PCRE_REGEX and PCRE_OPT=PCRE_CASELESS to either the whole project, or the build-target, where it is needed in the "#defines" tab of the "Compiler settings".

If you need variables changing on special conditions, you can use the scripting system (http://wiki.codeblocks.org/index.php?title=Scripting).

Offline rv2931

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: extract some variables from a custom makefile ?
« Reply #2 on: November 20, 2008, 04:13:36 pm »
I just put
Compiler flags|other options | #define                             
USE_PCRE_REGEX
PCRE_OPT=PCRE_CASELESS

in the #define section of the Build option, for debug and release.
and then, i have an error :
mingw32-gcc : = : No such file or directory
mingw32-gcc : PCRE_CASELESS : No such file or directory
... ???
I leave the = sign, but the second message remains, so this doesn't work like this
any idea ?

Offline rv2931

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: extract some variables from a custom makefile ?
« Reply #3 on: November 20, 2008, 04:35:59 pm »
In fact it seems to work by specifying /DPCRE_CASELESS /DPCRE_OPT=PCRE_CASELESS in the #define area instead of USE_PCRE_REGEX and PCRE_OPT=PCRE_CASELESS like what I did before, sorry

I have now an other problem
when I use my library generated with this options, I have just one error : undefined reference to '_pcre_free'
this is the only pcre function that causes this type of error

why does the compiler find the definition of the other functions and does not only for this ?
In an another post, I was told that I have to define PCRE_STATIC before including pcre.h, but it doesn't work...

mariocup

  • Guest
Re: extract some variables from a custom makefile ?
« Reply #4 on: November 20, 2008, 05:36:44 pm »
Hi rv2931,

I my eyes this seems to be a linker error message. If you pass libraries to the linker the order is relevant to resolve references. If you want to force the linker to resolve cyclic references just surround them by using -Wl,--start-group <list of libs> -Wl,--end-group or as linker option --start-group <list of libs> --end-group .

Bye,

Mario

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: extract some variables from a custom makefile ?
« Reply #5 on: November 20, 2008, 06:16:50 pm »
Here is a quote from the other thread where you asked about this issue:

Did you read the documentation?
Quote
If you want to statically link against the .a file, you must define PCRE_STATIC before including pcre.h, otherwise the pcre_malloc and pcre_free exported functions will be declared __declspec(dllimport), with hilarious results.