Author Topic: Mac OSX: How can I get it to find "wx"  (Read 14226 times)

Offline bnilsson

  • Almost regular
  • **
  • Posts: 184
Mac OSX: How can I get it to find "wx"
« on: August 30, 2006, 08:56:31 pm »
Platform: Dual 2.3GHz PowerMac G5, Mac OSX 10.4.7, Xcode Tools 2.4. wxWidgets 2.6.3
Code::Blocks 1.0 revision 2913

I am an absolute beginner in C::B, I just got the application running on Mac OSX.
I created a new wxWidgets project and tried to build it, but it failed to find the header in
#include <wx/wxprec.h>

I have tried to understand how to set up global variable, but failed.

The particular file that was not found resides in
/opt/local/include/wx-2.6/wx/
The libwx* libraries are in
/opt/local/lib

Any hints?


-- Ingnorance should not be taken for stupidity --

HW: PowerMac Dual PowerPC G5 2.3Ghz, 1GB RAM OS: MacOSX 10.4.10 Compiler: powerpc-apple-darwin8-gcc-4.0.1

sethjackson

  • Guest
Re: Mac OSX: How can I get it to find "wx"
« Reply #1 on: August 30, 2006, 10:19:14 pm »
Platform: Dual 2.3GHz PowerMac G5, Mac OSX 10.4.7, Xcode Tools 2.4. wxWidgets 2.6.3
Code::Blocks 1.0 revision 2913

I am an absolute beginner in C::B, I just got the application running on Mac OSX.
I created a new wxWidgets project and tried to build it, but it failed to find the header in
#include <wx/wxprec.h>

I have tried to understand how to set up global variable, but failed.

The particular file that was not found resides in
/opt/local/include/wx-2.6/wx/
The libwx* libraries are in
/opt/local/lib

Any hints?




I think you need to point the global variable wx to /opt/local/lib

HTH

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Mac OSX: How can I get it to find "wx"
« Reply #2 on: August 30, 2006, 11:47:38 pm »
The particular file that was not found resides in
/opt/local/include/wx-2.6/wx/
The libwx* libraries are in
/opt/local/lib

I normally use "wx-config" to find those.

Code: [Select]
CFLAGS=`wx-config --cflags`
CXXFLAGS=`wx-config --cxxflags`
LDFLAGS=`wx-config --libs`

Offline bnilsson

  • Almost regular
  • **
  • Posts: 184
Re: Mac OSX: How can I get it to find "wx"
« Reply #3 on: September 03, 2006, 11:37:12 am »
Quote
I normally use "wx-config" to find those.

Code:
CFLAGS=`wx-config --cflags`
CXXFLAGS=`wx-config --cxxflags`
LDFLAGS=`wx-config --libs`
Posted on: August 30, 2006, 04:19:14 PM

I am pretty convinced I do not know how to use this advice:

[Tiger:~] bnilsson% CFLAGS=`wx-config --cflags`
tcsh: CFLAGS=-I/opt/local/lib/wx/include/mac-ansi-release-static-2.6: Command not found.
[Tiger:~] bnilsson% CXXFLAGS=`wx-config --cxxflags`
tcsh: CXXFLAGS=-I/opt/local/lib/wx/include/mac-ansi-release-static-2.6: Command not found.
[Tiger:~] bnilsson% LDFLAGS=`wx-config --libs`
tcsh: LDFLAGS=-L/opt/local/lib: Command not found.
[Tiger:~] bnilsson%

How do I use the result?
-- Ingnorance should not be taken for stupidity --

HW: PowerMac Dual PowerPC G5 2.3Ghz, 1GB RAM OS: MacOSX 10.4.10 Compiler: powerpc-apple-darwin8-gcc-4.0.1

Offline Auria

  • Almost regular
  • **
  • Posts: 152
Re: Mac OSX: How can I get it to find "wx"
« Reply #4 on: September 03, 2006, 04:56:10 pm »
Calling 'wx-config' assumes you installed wx (e.g. make install) if you didn't do it, cd into the dir where you built (for me it's osx-build ) then call it - or you can also also copy inplace-mac-ansi-whatever into /usr/bin - i'm not sure how right it is to do that but at least it works fine for me

Offline Game_Ender

  • Lives here!
  • ****
  • Posts: 551
Re: Mac OSX: How can I get it to find "wx"
« Reply #5 on: September 03, 2006, 05:25:54 pm »
I believe that all Macs have wxMac 2.5 installed by default, so wx-config will give you that one.  I think the Darwin Ports installed wxMac wx-config override this, but you should check.

Offline bnilsson

  • Almost regular
  • **
  • Posts: 184
Re: Mac OSX: How can I get it to find "wx"
« Reply #6 on: September 03, 2006, 06:31:21 pm »
How do I use the result?
-- Ingnorance should not be taken for stupidity --

HW: PowerMac Dual PowerPC G5 2.3Ghz, 1GB RAM OS: MacOSX 10.4.10 Compiler: powerpc-apple-darwin8-gcc-4.0.1

Offline Auria

  • Almost regular
  • **
  • Posts: 152
Re: Mac OSX: How can I get it to find "wx"
« Reply #7 on: September 03, 2006, 08:13:31 pm »
wx-config --cxxflags and friends, will give you the compiler flags required to build wxWidget projects

you'll need to learn what are and where to put compiler flags if you don't know (and your questions makes me think so)

And since you're on mac... you could use the wx framework that comes with your computer with a single flag: -framework wxWidgets (or whatever it's called, i don't know, i don't have it on 10.3)

Since this is Code::Blocks forum, i'm assuming you're using Code::Blocks? Though it seems like you're on mac, and Code::Blocks for mac is kind of early and unstable. If you really want to use it, then just find the area where compiler and linker flags go and paste the right flags there.

Or use the wxWidgets project template. It works fine over here on 10.3.9 computer with wx 2.7. If it doesn't work for you it might be a hint that you didn't install wxWidgets properly? wx-config should really not cause problems... or maybe it's a 10.4 problem

you said you're an absolute beginner in Code::blocks, but are you an absolute beginner in programming in general, or just in Code::blocks?

And how did you install wx?
« Last Edit: September 03, 2006, 08:20:04 pm by Auria »

Offline bnilsson

  • Almost regular
  • **
  • Posts: 184
Re: Mac OSX: How can I get it to find "wx"
« Reply #8 on: September 03, 2006, 09:53:40 pm »
Quote
wx-config --cxxflags and friends, will give you the compiler flags required to build wxWidget projects

you'll need to learn what are and where to put compiler flags if you don't know (and your questions makes me think so)
Absolutely true.
Quote

And since you're on mac... you could use the wx framework that comes with your computer with a single flag: -framework wxWidgets (or whatever it's called, i don't know, i don't have it on 10.3)

..that comes with my computer..? wxWidgets is not bundled with Mac OS X 10.4.7 as far as I know.

Quote
Since this is Code::Blocks forum, i'm assuming you're using Code::Blocks? Though it seems like you're on mac, and Code::Blocks for mac is kind of early and unstable.
Do you suggest I get myself a WinPC and start learing Code::Blocks there, to get a feeling for the "normal" programming enviroment first?
Quote
If you really want to use it, then just find the area where compiler and linker flags go and paste the right flags there.
Which brings me to the fundamental question:
Do I need a global variable or a compiler flag to define the meaning of "wx"?
Quote
Or use the wxWidgets project template.
That's exactly what I did.
I created a "wxWidgets application" from the template wizard.
Pressing "Build" immidiately gave an error message
"./wx_pch.h     9      error: wx/wxprec.h: No such file or directory"
which led me to assume that wx was not defined since the file existed at the expected location.
I would have expected a wxWidgets template should have included the proper flags if needed. If they had existed but pointed in the wrong direction, I could have found them and modified it accordingly. But there was nothing.
Quote
It works fine over here on 10.3.9 computer with wx 2.7. If it doesn't work for you it might be a hint that you didn't install wxWidgets properly? wx-config should really not cause problems... or maybe it's a 10.4 problem

you said you're an absolute beginner in Code::blocks, but are you an absolute beginner in programming in general, or just in Code::blocks?
I have been using CodeWarrior C/C++ for true cross-platform applications on Mac and WinPC for about 15 years.
I have been programming in the unix environment since I got my first Mac OSX, mainly continuing making source code. However, I am unexperienced in the programming environment setup such as  writing Makefiles and understanding a proper gcc command line. I have gone as far as doing ./configure and make on opensource projects found on the net. I have also copied Makefiles from small projects and modified them to work with my own source code, not really understanding everything I've been doing.
I was hoping to port my cross-platform work from MWCW to someting more modern since the MWCW support stopped at OS X SDK 10.3.9.
It looked like Code::Blocks would help me avoiding commandline compiling, at least for a while, and still extend my cross-platform work to unix. I have some tru64 systems at my work that I would like to port some software to. But is teems I might have been too optimistic.
Quote
And how did you install wx?
By ./configure --prefix=/opt/local,  make, make install.
-- Ingnorance should not be taken for stupidity --

HW: PowerMac Dual PowerPC G5 2.3Ghz, 1GB RAM OS: MacOSX 10.4.10 Compiler: powerpc-apple-darwin8-gcc-4.0.1

Offline bnilsson

  • Almost regular
  • **
  • Posts: 184
Re: Mac OSX: How can I get it to find "wx"
« Reply #9 on: September 03, 2006, 10:30:49 pm »

I just want to add that I until recently used CPLAT2 for cross-platform GUI projects, but I have a feeling I have reached the end of that line. However, it worked rather well in the latesr versions. It worked with MWCW8.3 for MacOSX and WinPC, but still incompatible with the latest OSX SDKs and unix environments. Many unix projects that I was working on required headers that just did not fit in this environment, making it impossible to port into such a GUI project.

-- Ingnorance should not be taken for stupidity --

HW: PowerMac Dual PowerPC G5 2.3Ghz, 1GB RAM OS: MacOSX 10.4.10 Compiler: powerpc-apple-darwin8-gcc-4.0.1

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2180
Re: Mac OSX: How can I get it to find "wx"
« Reply #10 on: September 03, 2006, 11:19:26 pm »
Note the backticks



« Last Edit: September 03, 2006, 11:21:01 pm by Pecan »

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2180
Re: Mac OSX: How can I get it to find "wx"
« Reply #11 on: September 03, 2006, 11:28:35 pm »

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Mac OSX: How can I get it to find "wx"
« Reply #12 on: September 03, 2006, 11:41:33 pm »
Quote
I normally use "wx-config" to find those.

I am pretty convinced I do not know how to use this advice:
...
How do I use the result?

Sorry, that exact code (verbatim) was from the Makefiles that I still use...
I meant that you could enter it in the proper C::B dialogs, as Pecan showed.

There is no "framework" provided for Mac OS X, just dynamic libraries (dylib).
But I'm probably going to provide a framework in the wxD project, eventually.

Basically the wx.framework consists of the libraries and the headers, bundled.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2180
Re: Mac OSX: How can I get it to find "wx"
« Reply #13 on: September 03, 2006, 11:56:03 pm »

Offline Auria

  • Almost regular
  • **
  • Posts: 152
Re: Mac OSX: How can I get it to find "wx"
« Reply #14 on: September 04, 2006, 02:05:11 am »
Quote
I have been using CodeWarrior C/C++ for true cross-platform applications on Mac and WinPC for about 15 years.
I have been programming in the unix environment since I got my first Mac OSX, mainly continuing making source code. However, I am unexperienced in the programming environment setup such as  writing Makefiles and understanding a proper gcc command line. I have gone as far as doing ./configure and make on opensource projects found on the net. I have also copied Makefiles from small projects and modified them to work with my own source code, not really understanding everything I've been doing.
I was hoping to port my cross-platform work from MWCW to someting more modern since the MWCW support stopped at OS X SDK 10.3.9.
It looked like Code::Blocks would help me avoiding commandline compiling, at least for a while, and still extend my cross-platform work to unix. I have some tru64 systems at my work that I would like to port some software to. But is teems I might have been too optimistic.

If you can program C/C++, you certainly can learn command-line arguments :) just give it a try, it's not hard and will help a lot your understanding of things

You know, using the command-line isn't a way to complicate easy things. I'm not saying you should compile everything from the command-line. It's just that understanding what messages you can give to the compiler will make it much easier to compile stuff.

Quote
Do you suggest I get myself a WinPC and start learing Code::Blocks there, to get a feeling for the "normal" programming enviroment first?

I suggest that on mac you should use XCode until Code::Blocks gets better, or until you have a better understanding of the build process. Though it won't save you from using compiler flags either. (Well i don't know how Code::Blocks behaves on 10.4 -- maybe it's more usable than on 10.3) However, if you need cross-platform, of course it won't work. Either use Code::Blocks, but knowing it may not work properly. For instance, on my compuer, Code::blocks isn't able to run projects or to debug.

Quote
By ./configure --prefix=/opt/local,  make, make install.
I'm not an expert at building wx, but if i'm not mistaken you're building a shared library... Hope you know what it means? I built static. Might be why it worked for me and not for you?

Quote
Do I need a global variable or a compiler flag to define the meaning of "wx"?
Haven't read everything so i could be wrong, but i believe the global variable was the path to 'wx-config'. If you don't install 'wx-config' into /usr folders, or if some program can't find it, you can define a global variable pointing to it.

Once you know where is 'wx-config', you can ask it to give you the required compiler flags and paste them in the right fields (or, as Pecan showed you, you can also make 'wx-config' give the flags directly to code::blocks)

then, the compiler, by reading the flags will be able to build a proper wxWidgets app
« Last Edit: September 04, 2006, 02:12:34 am by Auria »

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2180
Re: Mac OSX: How can I get it to find "wx"
« Reply #15 on: September 04, 2006, 03:11:58 am »
Quote
(Well i don't know how Code::Blocks behaves on 10.4 -- maybe it's more usable than on 10.3) However, if you need cross-platform, of course it won't work. Either use Code::Blocks, but knowing it may not work properly. For instance, on my compuer, Code::blocks isn't able to run projects or to debug.

My experience is that Mac CB works fine for me on 10.3.9 both for compiling and debugging.

I compile CB with CB weekly (sometimes more often). And thats a big complicated project.

Admittedly, there are some quirks in the UI. But they're not that bothersome.
« Last Edit: September 04, 2006, 03:19:03 am by Pecan »

Offline Auria

  • Almost regular
  • **
  • Posts: 152
Re: Mac OSX: How can I get it to find "wx"
« Reply #16 on: September 04, 2006, 03:36:54 am »
Nice it's working for you... but for me trying to run even the simplest project results in

Checking for existence: /[...]/project_name/project_name
Executing: xterm -T 'hg' -e 'LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH "/[...]/project_name" ' (in /[...]/project_name/.)
Process terminated with status 255 (0 minutes, 0 seconds)

(Or maybe it happens because i haven't configured something properly? I believed hitting 'run' should be okay but now i realize i should maybe have investigated a bit further...)

I know Code::Blocks on mac can be used, be probably still needs testing and might not fit the needs of someone looking for a well-tested reliable tool

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Mac OSX: How can I get it to find "wx"
« Reply #17 on: September 04, 2006, 01:31:25 pm »
The run path is currently still defaulting to use X11 and "xterm",
we need to set it to open the Terminal.app on Mac OS X (wxMac)

(i.e. it's a bug)

I usually set mine (C::B) to just run the produced binary/exe directly,
and it will open up a Terminal window if needed - or just run the GUI.

Offline bnilsson

  • Almost regular
  • **
  • Posts: 184
Re: Mac OSX: How can I get it to find "wx"
« Reply #18 on: September 04, 2006, 10:22:44 pm »
Okay, all

I have go a big bunch of advice, so I understand things a little bit better now, I think.
I put in all the parameters given to me here into the project settings, but unfortunately it did not solve my initial question:

Line 9 in ./wx_pch.h in my barebones wxWidgets template project,
#include <wx/wxprec.h>
gives an error during the generation of the precompiled headers that the file is not found.
So it still don't know where wx is.

Again, the complete path to wxprec.h is:
/opt/local/include/wx-2.6/wx/wxprec.h

What more can I do?

-- Ingnorance should not be taken for stupidity --

HW: PowerMac Dual PowerPC G5 2.3Ghz, 1GB RAM OS: MacOSX 10.4.10 Compiler: powerpc-apple-darwin8-gcc-4.0.1

Offline Auria

  • Almost regular
  • **
  • Posts: 152
Re: Mac OSX: How can I get it to find "wx"
« Reply #19 on: September 04, 2006, 10:48:20 pm »
What'S the exact error messgae? 'gives an error that the file is not found' does not exactly sound obvious to me :lol:

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2180
Re: Mac OSX: How can I get it to find "wx"
« Reply #20 on: September 05, 2006, 12:33:26 am »
Please turn on full compiler logging

Settings->Compiler and Debugger->"Other"->Compiler logging = "Full command line".

Then post the compiler command line Along with the error message window
for that compile.


Offline bnilsson

  • Almost regular
  • **
  • Posts: 184
Re: Mac OSX: How can I get it to find "wx"
« Reply #21 on: September 05, 2006, 08:41:01 pm »
The log field is not handling the clipboard as it should, so I have to post a screen part:



[attachment deleted by admin]
-- Ingnorance should not be taken for stupidity --

HW: PowerMac Dual PowerPC G5 2.3Ghz, 1GB RAM OS: MacOSX 10.4.10 Compiler: powerpc-apple-darwin8-gcc-4.0.1

Offline bnilsson

  • Almost regular
  • **
  • Posts: 184
Re: Mac OSX: How can I get it to find "wx"
« Reply #22 on: September 05, 2006, 09:01:19 pm »


I guess it is solved.
In "Compiler and debugger settings/Global compiler/Programs/Additional Paths" i added "/opt/local/bin".
Then the wx project built without errors.

Thank you all for your attention to help me thru.

-- Ingnorance should not be taken for stupidity --

HW: PowerMac Dual PowerPC G5 2.3Ghz, 1GB RAM OS: MacOSX 10.4.10 Compiler: powerpc-apple-darwin8-gcc-4.0.1

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2180
Re: Mac OSX: How can I get it to find "wx"
« Reply #23 on: September 06, 2006, 03:24:20 am »


I guess it is solved.
In "Compiler and debugger settings/Global compiler/Programs/Additional Paths" i added "/opt/local/bin".
Then the wx project built without errors.

Thank you all for your attention to help me thru.

That would mean that /opt/local/bin became part of the path searched for executable programs. i.e., wx-config was found on the executable path.

You could have also solved it  by adding  /opt/local/bin to the "path" variable in your  user .profile

Offline bnilsson

  • Almost regular
  • **
  • Posts: 184
Re: Mac OSX: How can I get it to find "wx"
« Reply #24 on: September 06, 2006, 08:50:54 am »

Quote
You could have also solved it  by adding  /opt/local/bin to the "path" variable in your  user .profile

A bit strange, since 'wx-config' is readily available in my normal Terminal window.

Should CB import the normal user-defined path? It seems to me it does not do this.
-- Ingnorance should not be taken for stupidity --

HW: PowerMac Dual PowerPC G5 2.3Ghz, 1GB RAM OS: MacOSX 10.4.10 Compiler: powerpc-apple-darwin8-gcc-4.0.1

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2180
Re: Mac OSX: How can I get it to find "wx"
« Reply #25 on: September 06, 2006, 02:33:40 pm »

Quote
You could have also solved it  by adding  /opt/local/bin to the "path" variable in your  user .profile

A bit strange, since 'wx-config' is readily available in my normal Terminal window.

Should CB import the normal user-defined path? It seems to me it does not do this.

If wx-config is executable from terminal, it is reachable from the executable path. If so, I don't understand why you received
"wx-config: command not found" in your previous msg. It's a mystery to me.


Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Mac OSX: How can I get it to find "wx"
« Reply #26 on: September 06, 2006, 07:50:44 pm »
Maybe he set the PATH for some weird shell like "csh",
but Code::Blocks uses a sane shell like "sh" ? Perhaps.

To avoid tripping, I've not included /opt/local/bin in mine.
Avoids mixing up DarwinPorts and System/Local programs.

Offline bnilsson

  • Almost regular
  • **
  • Posts: 184
Re: Mac OSX: How can I get it to find "wx"
« Reply #27 on: September 06, 2006, 10:29:59 pm »
I am using /bin /tcsh.
This is my PATH:
[Tiger:~] bnilsson% echo $PATH
/bin:/sbin:/usr/bin:/usr/sbin:/Users/bnilsson/bin:/opt/local/bin:/usr/local/bin:/usr/X11R6/bin:/Developer/Tools

BTW, why is "/bin /tcsh" without space a forbidden word here? I get "Forbidden" if I try to post or preview it.


-- Ingnorance should not be taken for stupidity --

HW: PowerMac Dual PowerPC G5 2.3Ghz, 1GB RAM OS: MacOSX 10.4.10 Compiler: powerpc-apple-darwin8-gcc-4.0.1