Author Topic: CodeBlocks and contrib projects for MacOSX 10.4  (Read 8643 times)

Offline bnilsson

  • Almost regular
  • **
  • Posts: 184
CodeBlocks and contrib projects for MacOSX 10.4
« on: November 04, 2006, 08:25:48 am »
With some help from Pecan I have adapted a .cbp projects that builds CodeBlocks and contrib plugins on MacOSX 10.4 using CodeBlocks.

What came as a surprise to me was that the frontpage buttons and icons (New project, Open project, Recent projects, etc.) was working instantly on CodeBlocks built by the CodeBlocks-mac104.cbp, while these functions are not working (at least for me) when building CB from command line.

The attached package also contains a modified update script (update-mac) plus a bundle script to make a CodeBlocks.app bundle.

Test it with care, so you don't ruin existing installations.

 

[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 Game_Ender

  • Lives here!
  • ****
  • Posts: 551
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #1 on: November 04, 2006, 08:33:30 am »
Are these going to be submitted to as patches for CB?  I am starting a project at my university and I have several Mac team members.  It would be a great boon to the project to only have to support one C++ IDE.

Offline takeshi miya

  • Lives here!
  • ****
  • Posts: 1487
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #2 on: November 03, 2006, 09:27:37 pm »
Hi,

this is nice, it would be even nicer if it could be mantained by someone with commit access over svn,

the unix cbp's are almost the same, with some differences, so you could
a) maintain a set of patches to output -mac.cbp's based on the -unix.cbp's
b) maintain a different set of projects (lot of burden maintenance)
c) maintain a sed script to output -mac.cbp's based on the -unix.cbp's.
d) maintain a set of build scripts (squirrel) for the -unix.cbp's (this is the one I like most)


some things to note in the projects attached:
1) you use
<Option output="devel/libwxscintilla.dylib" prefix_auto="0" extension_auto="0" />
but it is not necessary, the idea is to use prefix_auto="1" and extension_auto="1" so CodeBlocks guesses the prefix and extension automatically,
so here, we cut the "diff" a bit,

2) I can see that you use sometimes <Add option="`wx-config --libs`" /> in both the Projects and the Targets, it is not necessary to be in both, just use one of the two, and leave the same as the -unix.cbp's

3) there is <Add option="-D__WXMAC__" /> usage,
question: doesn't wx-config --cxxflags defines that automatically?

4) I see inclusion of <Add directory="/usr/lib" /> and <Add directory="/usr/local/lib" />,
for which library is this necessary? if for wx, that's not good,
the problem in hard-coding this system path in the project is that, for example, if you want to use the wx from MacPorts (/opt/local/lib) the above path will override it; I think it's better to leave the user to define those system paths in their own linker paths.
linking to /usr/lib/libSystem.dylib directly is rather OK because you don't bring all the paths to the linker

Offline bnilsson

  • Almost regular
  • **
  • Posts: 184
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #3 on: November 03, 2006, 09:34:59 pm »
Thanks for the comment, I will implement the suggested changes.
I got the project from Pecan as being 10.3 compatible, and after I got it to build without errors on 10.4.8, I did not proceed much further.
I will send an updated version as soon as I see that it is working with your suggested changes.
Any further comments will be much appreciated.
-- 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: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #4 on: November 03, 2006, 11:10:48 pm »
I was able to do away with 3) and 4) but not 1) and 2).
1) libwxscintilla apparently needs to be a .dylib, automatic extension makes it a .so, and this does not link. I did not see auto prefix do anything at all.
2) removing `wx-config -libs`from "sdk" and "src" targets caused link errors against wx.

Major other changes to fix the above I guess would be contraproductive if the issue is to have as little differences as possible vs. -unix.cbp.
But of course, suggestions are welcome.


I will go thru the plugins/contrib projects also to see if I can remove some unnecessary stuff there also.
-- 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 takeshi miya

  • Lives here!
  • ****
  • Posts: 1487
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #5 on: November 04, 2006, 12:20:37 am »
1) libwxscintilla apparently needs to be a .dylib, automatic extension makes it a .so, and this does not link. I did not see auto prefix do anything at all.
well then c::b needs a little fix, on Mac autoextension should change it to .dylib, not .so

2) removing `wx-config -libs`from "sdk" and "src" targets caused link errors against wx.
there's probably a linker-order error, I was talking about plugins anyways; let's take an example, codesnippets plugin:

there's this in the Target:
Code: XML
  1. <Linker>
  2.         <Add option="`wx-config --libs`" />
  3.         <Add directory="../../../devel" />
  4. </Linker>
  5.  

and you added this in the Project:
Code: XML
  1. <Linker>
  2.         <Add option="`wx-config --libs`" />
  3.         <Add option="-bundle" />
  4.         <Add library="libcodeblocks" />
  5.         <Add library="libwxscintilla" />
  6. </Linker>
  7.  

so the suggestion is to merge all in the Project for example:
Code: XML
  1. <Linker>
  2.         <Add option="`wx-config --libs`" />
  3.         <Add directory="../../../devel" />
  4.         <Add option="-bundle" />
  5.         <Add library="codeblocks" />
  6.         <Add library="wxscintilla" />
  7. </Linker>
  8.  

well that's it,

here comes the interesting part, build scripts:
http://wiki.codeblocks.org/index.php?title=Build_scripts

if you can create build scripts instead of new -mac.cbp's it would be a lot nicer,
something like this in the above case:
Code: C++
  1. function SetBuildOptions(base)
  2. {
  3.     // no PLATFORM_MAC for now, btw the logic in sdk/scripting/bindings/sc_consts.cpp
  4.     // is wrong because there is gtk for mac =P
  5.     if (PLATFORM == PLATFORM_UNKNOWN)
  6.     {
  7.         base.AddLinkerOption(_T("-bundle"));
  8.         base.AddLinkLib(_T("codeblocks"));
  9.         base.AddLinkLib(_T("wxscintilla"));
  10.     }
  11. }
  12.  
  13. function UnsetBuildOptions(base)
  14. {
  15.     if (PLATFORM == PLATFORM_UNKNOWN)
  16.     {
  17.         base.RemoveLinkerOption(_T("-bundle"));
  18.         base.RemoveLinkLib(_T("codeblocks"));
  19.         base.RemoveLinkLib(_T("wxscintilla"));
  20.     }
  21. }
  22.  
« Last Edit: November 04, 2006, 12:48:19 am by takeshi miya »

sethjackson

  • Guest
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #6 on: November 04, 2006, 12:42:57 am »
here comes the interesting part, build scripts:
http://wiki.codeblocks.org/index.php?title=Build_scripts

if you can create build scripts instead of new -mac.cbp's it would be a lot nicer,
something like this in the above case:
Code: C++
  1. function SetBuildOptions(base)
  2. {
  3.     // no PLATFORM_MAC for now, btw the logic in sdk/scripting/bindings/sc_consts.cpp
  4.     // is wrong because there is gtk for mac =P
  5.     if (PLATFORM == PLATFORM_UNKNOWN)
  6.     {
  7.         base.AddLinkerOption(_T("-bundle"));
  8.         base.AddLinkLib(_T("codeblocks"));
  9.         base.AddLinkLib(_T("wxscintilla"));
  10.     }
  11. }
  12.  
  13. function UnsetBuildOptions(base)
  14. {
  15.     if (PLATFORM == PLATFORM_UNKNOWN)
  16.     {
  17.         base.RemoveLinkerOption(_T("-bundle"));
  18.         base.RemoveLinkLib(_T("codeblocks"));
  19.         base.RemoveLinkLib(_T("wxscintilla"));
  20.     }
  21. }
  22.  


I agree.

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #7 on: November 04, 2006, 12:46:24 am »
What came as a surprise to me was that the frontpage buttons and icons (New project, Open project, Recent projects, etc.) was working instantly on CodeBlocks built by the CodeBlocks-mac104.cbp, while these functions are not working (at least for me) when building CB from command line.

Interesting, I can see if I can isolate what the bug fix for wxMac turned out to be then...

I've fixed the issues with opening files and with locating the prefix, so will commit those.

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #8 on: November 04, 2006, 01:07:54 am »
FYI: Info.plist for the application will be probably done as codeblocks.plist, generated automatically from codeblocks.plist.in with the current SVN revision, and with support for all of the file types (incl. icons)

See:
http://www.algonet.se/~afb/wx/codeblocks.plist
http://www.algonet.se/~afb/wx/icons48.zip


Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #9 on: November 04, 2006, 01:23:18 am »
Also, with autotools wxscintilla is statically linked (libwxscintilla.a)

Offline takeshi miya

  • Lives here!
  • ****
  • Posts: 1487
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #10 on: November 04, 2006, 02:08:18 am »
To accomplish d) and 1) fixing C::B itself was needed,
so I've uploaded a little patch for wxMac here: https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=1622&group_id=5358

afb, can you check that it works / doesn't overlaps with your patches?

Offline bnilsson

  • Almost regular
  • **
  • Posts: 184
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #11 on: November 04, 2006, 10:50:57 am »
Where should the contents of Icons48 be placed?
-- 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 afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #12 on: November 04, 2006, 11:19:34 am »
Where should the contents of Icons48 be placed?

Sorry, the icons should go next to the other ones in src/src/resources/icons
(in the CodeBlocks.app bundle they should go in the Resources dir, as usual)

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #13 on: November 04, 2006, 11:26:45 am »
https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=1622&group_id=5358

afb, can you check that it works / doesn't overlaps with your patches?

Seems to apply cleanly, I haven't used Code::Blocks to build itself much.

Offline bnilsson

  • Almost regular
  • **
  • Posts: 184
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #14 on: November 04, 2006, 12:18:15 pm »
takeshi,

Sorry, I had to reverse your patch for pluginmanager, since no plugins loaded when applied.
-- 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 afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #15 on: November 04, 2006, 12:21:27 pm »
takeshi,

Sorry, I had to reverse your patch for pluginmanager, since no plugins loaded when applied.

Right, it shouldn't use "dylib" for the plugins - those are "bundle" or "so" ( as used now)

Missed that on the cursory glance

Offline takeshi miya

  • Lives here!
  • ****
  • Posts: 1487
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #16 on: November 04, 2006, 04:03:23 pm »
Hi,

can you enlighten me?
on mac the shared libraries doesn't have a .dylib or .bundle extension?
plugins are share libraries right? what about wxscintilla, isn't a shared library too? why it needs the .dylib extension where the plugins not?

I'll update the patch accordingly

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #17 on: November 04, 2006, 04:26:27 pm »
can you enlighten me?
on mac the shared libraries doesn't have a .dylib or .bundle extension?

"Yes". As in: the shared libraries come in two different variants on Mac OS X.

See http://developer.apple.com/documentation/DeveloperTools/Conceptual/MachOTopics/Articles/loading_code.html

Quote
plugins are share libraries right?
"loadable bundle" (.so or .bundle)

/usr/bin/file command says: Mach-O bundle

Quote
what about wxscintilla, isn't a shared library too?
"dynamic library" (.dylib or .framework)

/usr/bin/file command says: Mach-O dynamically linked shared library

Quote
why it needs the .dylib extension where the plugins not?

I'll update the patch accordingly

libwxscintilla, libcodeblocks, libwx_mac-2.6 etc. => dylibs
C::B plugins, perl modules, python modules, etc. => bundles

Hope that helps.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2142
Re: CodeBlocks and contrib projects for MacOSX 10.4
« Reply #18 on: November 04, 2006, 06:08:04 pm »
Hi,

can you enlighten me?
on mac the shared libraries doesn't have a .dylib or .bundle extension?
plugins are share libraries right? what about wxscintilla, isn't a shared library too? why it needs the .dylib extension where the plugins not?

I'll update the patch accordingly

I try to remember it this way:

A program links against (uses) a dll: dll = dylib
A dll links against (uses) a program: dll = bundle
« Last Edit: November 04, 2006, 06:10:32 pm by Pecan »