Author Topic: How to setup wxwidgets in code::blocks Linux  (Read 31674 times)

rowck001

  • Guest
How to setup wxwidgets in code::blocks Linux
« on: April 24, 2006, 07:37:08 am »
Ok - I switched to Linux   8) (I have DialogBlocks and wxWidgets installed)

How do I set up the code::blocks environment to use this library in Linux??

I installed as root for make install in wxwidgets complie - so I assume it went into /usr/local/share

Offline yop

  • Regular
  • ***
  • Posts: 387
Re: How to setup wxwidgets in code::blocks Linux
« Reply #1 on: April 24, 2006, 02:21:33 pm »
Open up a console and type:
Code
wx-config --version
If you see something as an output then we 're on the right track.
To your project now:
Project->Build Options->Compiler->Other Options add `wx-config --cflags` in there
Project->Build Options->Linker->Other Options add `wx-config --libs` in there
One final thing (don't know if this one is fixed). There is a bug that won't let the linker options work correctly so also do the following:
Project->Properties->Generate pch in a directory alongside... (the first option from above)
Enjoy...

P.S. what linux distro are you using? You don't *really* need to build wxWidgets from source, installing wxGTK from your distro's repository should be enough.
Life would be so much easier if we could just look at the source code.

rowck001

  • Guest
Re: How to setup wxwidgets in code::blocks Linux
« Reply #2 on: April 25, 2006, 09:21:30 am »
Thanks for the help

I am using Ubuntu Breezy and using its wxlibs deb packages doesnt give me the wxgtk....so.0 lib file so thats why I built from source

Incidently, should I have compiled as monolithic or shared library?

Offline yop

  • Regular
  • ***
  • Posts: 387
Re: How to setup wxwidgets in code::blocks Linux
« Reply #3 on: April 25, 2006, 09:40:36 am »
Generally prefer shared libraries. I don't really like the monolithic build, but I can understand the purpose of it in windows. In linux you can choose to go either way. If you want to get the C::B proposed build just take a look at the wiki.
Life would be so much easier if we could just look at the source code.

rowck001

  • Guest
Re: How to setup wxwidgets in code::blocks Linux
« Reply #4 on: April 25, 2006, 10:58:47 am »
Thanks for the help yop - but it doesnt work - after putting in the options you specified i still get this output from anf wxwidgets project:

Compiling: main.cpp
g++: `wx-config: No such file or directory
g++: `wx-config: No such file or directory
cc1plus: error: unrecognized command line option "-fcflags`"
cc1plus: error: unrecognized command line option "-fcflags`"
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings

wxwidgets works like a charm in kdevelop (straight out of the box) but not code::blocks

probably not a good idea to sprout code::blocks as cross-platform as it clearly doesnt work apart from trivial console applications in linux!

takeshimiya

  • Guest
Re: How to setup wxwidgets in code::blocks Linux
« Reply #5 on: April 25, 2006, 11:15:51 am »
Thanks for the help yop - but it doesnt work - after putting in the options you specified i still get this output from anf wxwidgets project:

Compiling: main.cpp
g++: `wx-config: No such file or directory
g++: `wx-config: No such file or directory
cc1plus: error: unrecognized command line option "-fcflags`"
cc1plus: error: unrecognized command line option "-fcflags`"
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings

wxwidgets works like a charm in kdevelop (straight out of the box) but not code::blocks

probably not a good idea to sprout code::blocks as cross-platform as it clearly doesnt work apart from trivial console applications in linux!

You've come across a known bug in C::B RC2 which has been fixed long ago. A little forum search would have revealed that... :roll:

There are two ways you can get it working:
-Go to Settings->Compiler->Other and set the build mode to "GNU make". Backticks will work with it.
or
-Download and install a nightly build.

I recommend the later.

rowck001

  • Guest
Re: How to setup wxwidgets in code::blocks Linux
« Reply #6 on: April 25, 2006, 03:28:11 pm »
OK! I'm running Linux ... so I'll get a nightly Build which only is available for Windows!!  Hmmmm...... sounds like a good option  :x
 I guess kdevelop is looking good!

Offline PsYhLo

  • Almost regular
  • **
  • Posts: 157
Re: How to setup wxwidgets in code::blocks Linux
« Reply #7 on: April 25, 2006, 03:52:12 pm »
compile your own copy of SVN revision like i do for win
everyting is ok, works just fine


just do the things thats wrote here http://wiki.codeblocks.org/index.php?title=Nightly_Cookbook

sorry for my poor english

takeshimiya

  • Guest
Re: How to setup wxwidgets in code::blocks Linux
« Reply #8 on: April 25, 2006, 05:30:54 pm »
OK! I'm running Linux ... so I'll get a nightly Build which only is available for Windows!!  Hmmmm...... sounds like a good option  :x
 I guess kdevelop is looking good!
Could you instead take at least 1 minute for reading?
There are nightly builds being made for Redhat FC4 and Ubuntu 5.10, and that is linux.
If you don't have any of those distros you can compile it from svn yourself as PsYhLo pointed out.

If you don't want to do anything of that (!) I gave you another solution... Change the build system to "GNU make".

A side note: KDevelop doesn't works for me out of the box, but I can't complain as I haven't readed anything about it.

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: How to setup wxwidgets in code::blocks Linux
« Reply #9 on: April 25, 2006, 05:35:43 pm »
OK! I'm running Linux ... so I'll get a nightly Build which only is available for Windows!!  Hmmmm...... sounds like a good option  :x
 I guess kdevelop is looking good!
i think you should use KDevelop, it's really better for you, they also have a good forum where you can ask for help there !

Andre

  • Guest
Re: How to setup wxwidgets in code::blocks Linux
« Reply #10 on: April 25, 2006, 08:14:02 pm »
You've come across a known bug in C::B RC2 which has been fixed long ago. A little forum search would have revealed that... :roll:

There are two ways you can get it working:
-Go to Settings->Compiler->Other and set the build mode to "GNU make". Backticks will work with it.
or
-Download and install a nightly build.

I recommend the later.

I have a nightly build (from yesterday) and i also have this problem. But the setting 'Settings->Compiler->Other->build mode is grayed out, so i can not change it. What can i do?

Thanks in advance,

Andre

takeshimiya

  • Guest
Re: How to setup wxwidgets in code::blocks Linux
« Reply #11 on: April 25, 2006, 09:43:24 pm »
I have a nightly build (from yesterday) and i also have this problem. But the setting 'Settings->Compiler->Other->build mode is grayed out, so i can not change it. What can i do?
No, that problem was solved after RC2 for C::B build method, so it should work with it. The "GNU make" build method was removed after RC2 too.

In your case, it's likely that you don't have wx-config installed.
Issue
Quote
wx-config --version
in a shell, and if it outputs something, it means that it is installed.
If it's not installed, you'll need to download a package that contains that script, usually called "wx-common".

Andre

  • Guest
Re: How to setup wxwidgets in code::blocks Linux
« Reply #12 on: April 25, 2006, 10:18:56 pm »
In your case, it's likely that you don't have wx-config installed.
Issue
Quote
wx-config --version
in a shell, and if it outputs something, it means that it is installed.
If it's not installed, you'll need to download a package that contains that script, usually called "wx-common".

The package wx-common is installed, wx-config --version says 2.6.1. I've made the settings yop told in the second post of this thread. But it seems that wx-config can not be found. Ouput of the build command:
Code
-------------- Build: default in wxSmith_project ---------------
g++ `wx-config --cflags` wx-config --cflags  -I.objs -I- -I.objs -I. -I/usr/include  -c app.cpp -o .objs/app.o
g++: wx-config: No such file or directory
cc1plus: note: obsolete option -I- used, please use -iquote instead
cc1plus: error: unrecognized command line option "-fcflags"
Process terminated with status 1 (0 minutes, 2 seconds)
0 errors, 0 warnings

In another Thread you also said
As a note to anyone using RC2, this can be solved as:

Quote
Go to Settings->Compiler->Other and set the build mode to "GNU make". Backticks work with it.

But i can not alter these settings as its grayed out. Should i switch away from the nightly build to RC2?

takeshimiya

  • Guest
Re: How to setup wxwidgets in code::blocks Linux
« Reply #13 on: April 25, 2006, 11:00:47 pm »
But i can not alter these settings as its grayed out. Should i switch away from the nightly build to RC2?
No, you're experiencing a different problem.
This thread may help you: http://forums.codeblocks.org/index.php?topic=2195.0

Andre

  • Guest
Re: How to setup wxwidgets in code::blocks Linux
« Reply #14 on: April 25, 2006, 11:20:06 pm »
No, you're experiencing a different problem.
This thread may help you: http://forums.codeblocks.org/index.php?topic=2195.0

Yep, did work for me.

Thanks,

Andre

takeshimiya

  • Guest
Re: How to setup wxwidgets in code::blocks Linux
« Reply #15 on: April 25, 2006, 11:29:35 pm »
No, you're experiencing a different problem.
This thread may help you: http://forums.codeblocks.org/index.php?topic=2195.0

Yep, did work for me.

Thanks,

Andre

Great. :)
Did you changed the shell to bash?

Andre

  • Guest
Re: How to setup wxwidgets in code::blocks Linux
« Reply #16 on: April 25, 2006, 11:41:36 pm »
Great. :)
Did you changed the shell to bash?

No, cause i don't have the Shell setting shown in the screenshot in the other thread. After reading the other thread i recognized that i missed the backsticks. I had the `wx-config --cflags` in the default settings and in the project settings, but in the default settings without the backsticks. I removed it from the project settings, added the backsticks to the default settings and then it worked.

But i had already downloaded the sources from SVN...   ;)

Regards,

Andre

Andre

  • Guest
Re: How to setup wxwidgets in code::blocks Linux
« Reply #17 on: April 25, 2006, 11:48:32 pm »
Forget all i said. While trying to get it work i added the '/usr/include/wx-2.6' directory to Project->Build Options->Directories->Compiler. If i remove this again it will not work anymore. I think i'll have to build Codeblocks from source and change the Shell to Bash.

Andre

takeshimiya

  • Guest
Re: How to setup wxwidgets in code::blocks Linux
« Reply #18 on: April 25, 2006, 11:52:08 pm »
I think i'll have to build Codeblocks from source and change the Shell to Bash.

It's not necessary: that setting has been moved to Settings->Environment.

Andre

  • Guest
Re: How to setup wxwidgets in code::blocks Linux
« Reply #19 on: April 26, 2006, 12:04:56 am »
It's not necessary: that setting has been moved to Settings->Environment.

If i click on Settings-Environment i get an exception and Codeblocks dies. I've put the Debug report here:

http://www.rotlaus.de/img/codeblocks.xml

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2773
Re: How to setup wxwidgets in code::blocks Linux
« Reply #20 on: April 26, 2006, 12:18:42 am »

If i click on Settings-Environment i get an exception and Codeblocks dies. I've put the Debug report here:


Is this a source build crash or a .deb package crash or what?

thanks
pecan

Andre

  • Guest
Re: How to setup wxwidgets in code::blocks Linux
« Reply #21 on: April 26, 2006, 10:13:20 am »
Is this a source build crash or a .deb package crash or what?

Its a .deb package crash. It was a package the user Micheal of this forum provided. Just testetd the new version (rev2377), but this crashes also.

Andre

  • Guest
Re: How to setup wxwidgets in code::blocks Linux
« Reply #22 on: April 26, 2006, 02:48:28 pm »
Is this a source build crash or a .deb package crash or what?

Its a .deb package crash. It was a package the user Micheal of this forum provided. Just testetd the new version (rev2377), but this crashes also.

I've build the actual SVN Version for myself and there are the environment settings working. But changing the shell to bash doesn't help. `wx-config --cflags` get not expanded on the command line. But ican compile if i put the wx directory to the compiler directories.

takeshimiya

  • Guest
Re: How to setup wxwidgets in code::blocks Linux
« Reply #23 on: April 26, 2006, 03:25:45 pm »
I've build the actual SVN Version for myself and there are the environment settings working. But changing the shell to bash doesn't help. `wx-config --cflags` get not expanded on the command line. But ican compile if i put the wx directory to the compiler directories.

Could you paste the output produced by wx-config --cflags and wx-config --libs in a command line?
Check also if the --cflags outputs the correct include dir.

And, could you paste your project.cbp to see if everything is ok?

Andre

  • Guest
Re: How to setup wxwidgets in code::blocks Linux
« Reply #24 on: April 26, 2006, 05:59:58 pm »
Could you paste the output produced by wx-config --cflags and wx-config --libs in a command line?
Check also if the --cflags outputs the correct include dir.

And, could you paste your project.cbp to see if everything is ok?

wx-config --cflags
Code
andre@main:~$ wx-config --cflags
-I/usr/lib/wx/include/gtk2-unicode-release-2.6 -I/usr/include/wx-2.6 -DGTK_NO_CHECK_CASTS -D__WXGTK__ -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D_LARGEFILE_SOURCE=1 -DNO_GCC_PRAGMA
The Directories are the right ones.

wx-config --libs
Code
andre@main:~$ wx-config --libs
-pthread   -lwx_gtk2u_xrc-2.6 -lwx_gtk2u_qa-2.6 -lwx_gtk2u_html-2.6 -lwx_gtk2u_adv-2.6 -lwx_gtk2u_core-2.6 -lwx_baseu_xml-2.6 -lwx_baseu_net-2.6 -lwx_baseu-2.6

The Project file:
Code
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
        <FileVersion major="1" minor="4" />
        <Project>
                <Option title="wxSmith_project" />
                <Option compiler="gcc" />
                <Build>
                        <Target title="default">
                                <Option output="wxSmith_project" />
                                <Option type="0" />
                                <Option compiler="gcc" />
                                <Option projectResourceIncludeDirsRelation="0" />
                        </Target>
                </Build>
                <Compiler>
                        <Add option="`wx-config --cflags`" />
                </Compiler>
                <Linker>
                        <Add option="`wx-config --libs`" />
                </Linker>
                <Unit filename="app.cpp">
                        <Option compilerVar="CPP" />
                        <Option target="default" />
                </Unit>
                <Unit filename="app.h">
                        <Option compilerVar="CPP" />
                        <Option compile="0" />
                        <Option link="0" />
                        <Option target="default" />
                </Unit>
                <Unit filename="mainframe.cpp">
                        <Option compilerVar="CPP" />
                        <Option target="default" />
                </Unit>
                <Unit filename="mainframe.h">
                        <Option compilerVar="CPP" />
                        <Option compile="0" />
                        <Option link="0" />
                        <Option target="default" />
                </Unit>
                <Unit filename="wx_pch.h">
                        <Option compilerVar="CPP" />
                        <Option link="0" />
                        <Option weight="0" />
                        <Option target="default" />
                </Unit>
                <Unit filename="wxsmith/MainFrame.wxs">
                        <Option compilerVar="CPP" />
                        <Option compile="0" />
                        <Option link="0" />
                        <Option target="default" />
                </Unit>
        </Project>

But it still doesn't compile. I loos like it doesn't expand the backsticked part to the shell. Here the last Build Log:
Code
-------------- Build: default in wxSmith_project ---------------
g++ `wx-config --cflags`  -I.objs -I- -I.objs -I. -I/usr/include  -c wx_pch.h -o .objs/wx_pch.h.gch
cc1plus: note: obsolete option -I- used, please use -iquote instead
wx_pch.h:9:23: error: wx/wxprec.h: No such file or directory
wx_pch.h:16:20: error: wx/wx.h: No such file or directory
Process terminated with status 1 (0 minutes, 1 seconds)
2 errors, 0 warnings
 

takeshimiya

  • Guest
Re: How to setup wxwidgets in code::blocks Linux
« Reply #25 on: April 26, 2006, 07:11:58 pm »
But it still doesn't compile. I loos like it doesn't expand the backsticked part to the shell. Here the last Build Log:
Code
-------------- Build: default in wxSmith_project ---------------
g++ `wx-config --cflags`  -I.objs -I- -I.objs -I. -I/usr/include  -c wx_pch.h -o .objs/wx_pch.h.gch
cc1plus: note: obsolete option -I- used, please use -iquote instead
wx_pch.h:9:23: error: wx/wxprec.h: No such file or directory
wx_pch.h:16:20: error: wx/wx.h: No such file or directory
Process terminated with status 1 (0 minutes, 1 seconds)
2 errors, 0 warnings
 

Ok, found your problem. Backticks are expanding correctly, wx-config is working correctly.
The problem is that the precompiled headers are being generated in the object output dir (default). For that to work GCC needs some header paths. But it's more easy to change the precompiled headers strategy.

Just open the project in a text editor and add after <Option title="wxSmith_project" />:
Code: xml
<Option title="wxSmith_project" />
<Option pch_mode="0" />

Or the GUI way: go to menu Project->Properties and in Precompiled headers, change the strategy to Generate PCH in a directory alongside original header.
Generate PCH alongside original header should work too.


Another thing: the warning that appears there cc1plus: note: obsolete option -I- used, please use -iquote instead is being generated by GCC4, which now use -iquote instead of -I-.

takeshimiya

  • Guest
Re: How to setup wxwidgets in code::blocks Linux
« Reply #26 on: April 26, 2006, 07:23:23 pm »
BTW, all it needs to fix this is a call to project->SetModeForPCH(pchSourceDir); in wxSmith's wxswizard.cpp, which was in a patch I sent to byo some weeks ago.

But it's high likely that the C::B new wizard system will be used for wxSmith wizard, so just do that in the meantime. 

Andre

  • Guest
Re: How to setup wxwidgets in code::blocks Linux
« Reply #27 on: April 26, 2006, 07:33:17 pm »
Just open the project in a text editor and add after <Option title="wxSmith_project" />:
Code: xml
<Option title="wxSmith_project" />
<Option pch_mode="0" />

Or the GUI way: go to menu Project->Properties and in Precompiled headers, change the strategy to Generate PCH in a directory alongside original header.
Generate PCH alongside original header should work too.

That did it. Works like intended. Thank you very much.

Regards,

Andre