Could not get programs working using wx2.8.8 on Leopard Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
vkantabu
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sun Aug 24, 2008 9:54 pm
Location: Pocatello, Idaho, U.S.A.
Contact:

Could not get programs working using wx2.8.8 on Leopard

Post by vkantabu » Sun Aug 24, 2008 10:19 pm

I tried to use wxWidgets 2.8.8 on a MacBook running Leopard with no success. I used the "all platform" source, and tried for the Mac version, and also tried the X11 version. I also tried using "port install." Then I also tried compiling the sources specialized to Mac and then the one specialized to X11. None of these worked, as explained below.

All these installations reported success. But when I tried running the "minimal.cpp" program in Chapter 2 of the textbook (by Smart, et al.), I ran into problems. Specifically, the frame came up, but the menus were inoperable. (Also, the frame didn't have the focus!) For the code, see http://wxd.sourceforge.net/minimal.cpp)

I also tried the "basic.cpp" example from a book by Cay Horstmann (See http://cplusplus.codefetch.com/example/ ... /basic.cpp) which is even simpler code that is supposed to show a frame that has nothing in it. Well, the code compiled with no complaints, but when I ran it I got either a "segmentation fault" or a "bus error" message, depending on which installation. I think the X11 installations gave me bus errors, whereas the other installations gave me segmentation faults!

I had wxWidgets working on the same MacBook before, when it was running Tiger. I don't remember which version of wx it was. Would love to have wx running on Leopard! Thanks.

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Sun Aug 24, 2008 11:12 pm

The no-focus problem happens because the application needs to be put inside an app bundle. The official samples' makefiles do that automatically usually, so if they did not for you i assume you did not compile them correctly.

See this article for a lengthy walkthrough : http://wiki.wxwidgets.org/Getting_started_on_OS_X

vkantabu
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sun Aug 24, 2008 9:54 pm
Location: Pocatello, Idaho, U.S.A.
Contact:

Could not get programs working using wx2.8.8 on Leopard

Post by vkantabu » Mon Aug 25, 2008 1:02 am

Being new to the forum, I pressed "accepted" and did not know that this meant that I thought the issue was solved. It was not solved, though I greatly appreciate the response.

I did compile using the suggested makefile. I don't believe that was the problem, and in any case the focus issue is a minor one. The major issues are the lack of working menu items and the bus error/segmentation fault.

By the way, after my first post I successfully get the same minimal.cpp example to work using wx 2.6.x on WinXP. So the issue may be specific to the wx 2.8/Leopard combination.

Thanks!


Original post:

I tried to use wxWidgets 2.8.8 on a MacBook running Leopard with no success. I used the "all platform" source, and tried for the Mac version, and also tried the X11 version. I also tried using "port install." Then I also tried compiling the sources specialized to Mac and then the one specialized to X11. None of these worked, as explained below.

All these installations reported success. But when I tried running the "minimal.cpp" program in Chapter 2 of the textbook (by Smart, et al.), I ran into problems. Specifically, the frame came up, but the menus were inoperable. (Also, the frame didn't have the focus!) For the code, see http://wxd.sourceforge.net/minimal.cpp)

I also tried the "basic.cpp" example from a book by Cay Horstmann (See http://cplusplus.codefetch.com/example/ ... /basic.cpp) which is even simpler code that is supposed to show a frame that has nothing in it. Well, the code compiled with no complaints, but when I ran it I got either a "segmentation fault" or a "bus error" message, depending on which installation. I think the X11 installations gave me bus errors, whereas the other installations gave me segmentation faults!

I had wxWidgets working on the same MacBook before, when it was running Tiger. I don't remember which version of wx it was. Would love to have wx running on Leopard! Thanks.

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Mon Aug 25, 2008 1:29 am

I "unnaccepted" the topic.
The major issues are the lack of working menu items
This is exactly what i meant by "focus issue", unless i misunderstood.
I did compile using the suggested makefile.
I'm not sure i understand what you mean. The wxWidgets code for mac includes no Makefile so i wonder what "suggested makefile" you're talking about. Did you use the configure script? If so what build flags did you use? etc.

Also, when you build samples, it's important that yu build those in /wxmac-2.8.x/your-build-folder/Samples, NOT those in /wxmac-2.8.x/Samples[/code]

vkantabu
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sun Aug 24, 2008 9:54 pm
Location: Pocatello, Idaho, U.S.A.
Contact:

Post by vkantabu » Mon Aug 25, 2008 2:06 am

Thanks for the reply! Forget the makefile. The command I used was: g++ minimal.cpp `wx-config --libs` `wx-config --cxxflags` -o minimal

he compilation went with no errors or warnings. However, it didn't run correctly. Also, I built the program in a very different directory from the ones you mentioned. It was done in a subdirectory of my regular user home directory.

By "focus" I mean that a window is ready to accept input. Has nothing to do with the menu.

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Mon Aug 25, 2008 2:51 pm

Simply building using "g++ minimal.cpp `wx-config --libs` `wx-config --cxxflags` -o minimal" is NOT sufficient. You need to build an app bundle. Either use XCode, either create the same structure from a script. See http://wiki.wxwidgets.org/WxMac_Issues# ... ion_bundle

Also, please describe the exact build procedure you use. the wxWidgets configure script automatically generates makefiles for all samples, like described in the link i posted above. Try using these makefiles first. Those are supposed to work.

vkantabu
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sun Aug 24, 2008 9:54 pm
Location: Pocatello, Idaho, U.S.A.
Contact:

Post by vkantabu » Mon Aug 25, 2008 7:09 pm

All right, I will study that procedure. I am surprised, since on Linux that command line was enough. (It's an old installation of wxWindows running on an old RedHat OS, don't remember the versions of either wx or RedHat.) On Windows XP with wx 2.6, I just used the IDE that came on the CD with Smart, et al.'s book (forgot the name of the IDE).

In compiling the various sources of wx on Leopard, I simply followed the default suggestion in the "INSTALLATION" documentation, except I became root before even compiling. So I think it was (approximately)

su
mkdir build-osx
cd build-osx
../configure (sometimes I tried some of the parameters suggested, but also tried with no parameters)
make
make install

Sorry, I don't have the documentation with me to verify that those were the exact steps, but I compiled so many times that I think that was the right sequence!

Thank you very much!

vkantabu
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sun Aug 24, 2008 9:54 pm
Location: Pocatello, Idaho, U.S.A.
Contact:

Post by vkantabu » Sat Aug 30, 2008 6:35 am

I followed the link on app bundles you suggested, but didn't understand it. Here is what I did today. Simply...

cd wxWidgets-2.8.8
mkdir build
cd build
../configure
make
cd samples/minimal
make
./minimal

The building of the wxWidgets and the sample both went OK, but the execution did not. Some library was missing. Here's what happened:

sh-3.2# ./minimal
dyld: Library not loaded: /usr/local/lib/libwx_base_carbon-2.8.0.dylib
Referenced from: /wxWidgets/wxWidgets-2.8.8/build/lib/libwx_mac_core-2.8.0.dylib
Reason: image not found
Trace/BPT trap

Is it the case that I didn't have that library and have to download it from somewhere, or is it that the building of the wxWidgets failed to load it in the right place?

Addendum: I just checked my /usr/local/lib directory. there is no file entry by the name of libwx..... at all! Why didn't the build of the wxWidgets put it there?

Thanks!!

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Sat Aug 30, 2008 3:08 pm

First, you shouldn't run with ./minimal, if you built properly on mac it will have generated an app bundle. Run it by double-clicking from the finder, or use the "open" terminal command

If it still doesn't work when in the app bundle, it seems like it is expecting you to do "sudo make install". Are you aware you are building wx as dynamic libraries? Unless you intend to make a program with plug-ins, building static will save you lots of trouble

vkantabu
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sun Aug 24, 2008 9:54 pm
Location: Pocatello, Idaho, U.S.A.
Contact:

Post by vkantabu » Sat Aug 30, 2008 8:49 pm

Thanks! Will try using the finder. But I'm curious - why not run from the command line? That's the usual Unix style anyway, and besides, I got those instructions from the installation tutorial that came with DialogBlocks. Those are the steps they suggested to do if one wants to test the wx installation before actually even installing DialogBlocks.

NO, I wasn't aware I was compiling dynamic libraries, but dynamic libraries should work anyway, I think. I still think that the errors I get indicates that there is a bug somewhere, because I was not doing anything out of the ordinary.

Anyway, I'll try what you suggested. Thanks!

vkantabu
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sun Aug 24, 2008 9:54 pm
Location: Pocatello, Idaho, U.S.A.
Contact:

Getting closer, but still not working

Post by vkantabu » Sat Aug 30, 2008 9:13 pm

Running the program by clicking on its icon in the Finder doesn't help. Same error message, as I would expect. But I'm trying something new. I am making the entire samples directory at once. Maybe the makefile at the samples directory level installs the missing library. Will post the result when I know it. Maybe will just edit this post. Thanks again! (Oh, yes, I'm using sudo this time, though I don't see why that would make a difference.)

NEWS: It is getting closer to working. Now the window comes up. But when I try to use the menus they don't work at all. I get a "bus error" message on the command line! Something is awfully wrong here. Has anyone out there installed this successfully on Leopard? I also tried the "drawing" example, with the same problem.

MORE NEWS: Actually I mistakenly made the samples that were directly underneath the wxWidgets2.8.8 home. So then I made the samples under the build directory, and the OLD problem of not finding the dynamic library happened again! I searched the Web for that problem, and found this post, unfortunately with no solution yet:
http://lists.wxwidgets.org/pipermail/wx ... 08088.html

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Sat Aug 30, 2008 11:29 pm

If you build as dynamic libs, as i said, you will likely need to issue "sudo make install" after "make"ing wxWidgets.

You need to open from the finder because it's not a unix app, it's a mac bundle. But if you wish to do it from terminal, as i said, there is the "open" command

vkantabu
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sun Aug 24, 2008 9:54 pm
Location: Pocatello, Idaho, U.S.A.
Contact:

Post by vkantabu » Sun Aug 31, 2008 12:26 am

I see! However, I get exactly the same error messages when I open it using the finder. So that strategy doesn't work.

However, your idea about trying static linking is worth trying. Actually, I followed the link I sent you in the previous email to Csomor's posting, and found that Julian Smart himself suggested static linking to somebody else who had exactly the same problem on Leopard. So I'll reconfigure wx accordingly and see what happens! I didn't see a posting after that one by Smart, and so I don't know whether or not the issue is resolved for the person who asked for help.

Apparently installing wx on Leopard is still new territory!

Thanks so much.

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Sun Aug 31, 2008 2:05 am

vkantabu wrote:I see! However, I get exactly the same error messages when I open it using the finder. So that strategy doesn't work.
As i already said twice, you will need to issue sudo make install before this works. Or une install_name_tool, or export DYLD_LIBRARY_PATH, etc. We're in dynamic librairies stuff here. make insall is probably your best bet if you want to remain dynamic. However...
vkantabu wrote: However, your idea about trying static linking is worth trying. Actually, I followed the link I sent you in the previous email to Csomor's posting, and found that Julian Smart himself suggested static linking to somebody else who had exactly the same problem on Leopard. So I'll reconfigure wx accordingly and see what happens! I didn't see a posting after that one by Smart, and so I don't know whether or not the issue is resolved for the person who asked for help.
This is also the way i'd recommend, dynamic librairies have advantages but static ones are usually much easier to manage. ut don't reconfigure wx, throw away you build dir and start from scratch, building over an old build with a new configuration is asking for trouble :)

vkantabu
Earned a small fee
Earned a small fee
Posts: 12
Joined: Sun Aug 24, 2008 9:54 pm
Location: Pocatello, Idaho, U.S.A.
Contact:

The samples work this time, finally!

Post by vkantabu » Mon Sep 01, 2008 1:23 am

The samples work this time, finally! Thank you very much. So it seems there is an unresolved bug when one tries to build wx dynamically on Leopard. The concept of an application bundle is new to me, and somehow I have to figure out how to make one when I write my own applications (rather than just modifying a sample)!

Post Reply