Author Topic: Installed but can't compile  (Read 19459 times)

jsimmons

  • Guest
Installed but can't compile
« on: August 14, 2005, 10:33:43 pm »
I installed wxWidgets 2.61 and CB RC1-1, and added the wxwdidgets includ and lib folders to the directories settings.  I then created a new project, and without adding anything to it other than what CB gave me, it won't compile. It can't seem to find "wx/wxprec.h".

Before today, I thought I was pretty sharp, but I can't for the life of me figure out what the heck I haven't done yet.  Any help?

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Installed but can't compile
« Reply #1 on: August 15, 2005, 12:13:43 am »
You should either:
have the wx folder copied into your include folder
or better:
add the wx folder to your compiler path (Build Options --> Directories --> Compiler).

wxprec.h is inside the wx folder. You can leave it out, too, and use wx.h instead, does the same thing basically, as precompilation does not work well in gcc yet. Precompiling wx.h by hand works better for me, but the gains are minimal anyway.

EDIT:
By the way... RC1-1 comes with wx2.4 rather than wx2.6. So if you want to use wx2.6, you will need to compile wxWidgets too, to get the libaries you link with. And believe me, compiling wx can be a nuisance... there is a WiKi on the code::blocks site about that, it may be helpful.
« Last Edit: August 15, 2005, 12:16:44 am by thomas »
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

jsimmons

  • Guest
Re: Installed but can't compile
« Reply #2 on: August 15, 2005, 03:04:18 am »
alrightie. I'll hack around some more and see what I come up with. :)

jsimmons

  • Guest
Re: Installed but can't compile
« Reply #3 on: August 15, 2005, 02:01:07 pm »
compiling wx can be a nuisance...

Has it struck anyone else that having to say this is a "bad thing" (tm)?

I'm kind of frustrated. I'm coming from Visual Studio 6 (I've been programming in C++ for the last 15 years), and I'm going to try converting over 500,000 lines of code to wxWidgets.  I can't even get a simple app created in CodeBlocks to compile (even using wx 2.4).  I have to say that the stuff I've found on the web is a bit convoluted.  I thought I'd be able to just install Code::Blocks and get to work, but I've been chasing my tail for almost three days trying to find everything I need to get started.  Am I the only one that has experienced this feeling.

I don't feel any better after having said all that, but I'll stop whining now and go back to chasing stuff around on the web... :roll:

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Installed but can't compile
« Reply #4 on: August 15, 2005, 02:40:26 pm »
Do you have things like WXUSINGDLL or __GNUWIN32__ (or whatever is suitable for your project) defined? That is what made me fail the first time I tried building a wxWindows app with code::blocks.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Installed but can't compile
« Reply #5 on: August 15, 2005, 02:54:51 pm »
Hello,

I think that the best solution is trying other than asking this forum (which is anyway very important) to look if you do not have missed some compiler/linker options and include/lib directories. If you use the free MS toolkit compiler, also look at the compiler hints:

http://wiki.codeblocks.org/index.php/Integrating_Microsoft_Visual_Toolkit_2003_with_Code::Blocks_IDE#Compiling_Hints

I have also had such frustrating experiences when trying DevC++ examples. Most of the time it was a missing parameter or a bad chosen one or the code automatically generated by the IDE was incorrect.

A search with Google could also be very useful.

Best wishes,
Michael

jsimmons

  • Guest
Re: Installed but can't compile
« Reply #6 on: August 15, 2005, 03:06:55 pm »
Do you have things like WXUSINGDLL or __GNUWIN32__ (or whatever is suitable for your project) defined? That is what made me fail the first time I tried building a wxWindows app with code::blocks.

I uninstalled and then re-installed, this time without adding wx 2.61.  I created a new project (I've tried it using static wx and the using the wx dll, both resulting in the same problem). My project compiler definitions are (I removed __WIN95__):

Code
WIN32
_WIN32
WINVER=0x0400
__GNUWIN32__
__WIN32__
STRICT
__WXMSW__
__WINDOWS__
WXUSINGDLL

I added the WX_VER=242 vcustom variable, and turned on "create debugging symbols".

I have the following in my includes directories:

Code
C:\Program Files\CodeBlocks\include

When I compile, I get this:

Code
Project   : wxWidgets application
Compiler  : GNU GCC Compiler (called directly)
Directory : C:\wxMedbase\
--------------------------------------------------------------------------------
Switching to target: default
Compiling: main.cpp
In file included from main.h:4,
                 from main.cpp:1:
app.h:4:23: wx/wxprec.h: No such file or directory
app.h:11:23: wx/wx.h: No such file or directory
In file included from main.h:4,
                 from main.cpp:1:
app.h:15: error: expected class-name before '{' token
In file included from main.cpp:1:
main.h:7: error: expected class-name before '{' token
main.h:9: error: expected `)' before '*' token
main.h:12: error: `wxCommandEvent' has not been declared
main.h:12: error: ISO C++ forbids declaration of `event' with no type
main.h:13: error: `wxCommandEvent' has not been declared
main.h:13: error: ISO C++ forbids declaration of `event' with no type
main.h:14: error: ISO C++ forbids declaration of `DECLARE_EVENT_TABLE' with no type
main.cpp:3: error: `wxNewId' was not declared in this scope
main.cpp:4: error: `wxNewId' was not declared in this scope
main.cpp:6: error: `wxFrame' has not been declared
main.cpp:7: error: expected constructor, destructor, or type conversion before "EVT_MENU"
main.cpp:7: error: expected `,' or `;' before "EVT_MENU"
main.cpp:30: error: variable or field `OnQuit' declared void
main.cpp:30: error: `int MyFrame::OnQuit' is not a static member of `class MyFrame'
main.cpp:30: error: `wxCommandEvent' was not declared in this scope
main.cpp:30: error: `event' was not declared in this scope
main.cpp:31: error: expected `,' or `;' before '{' token
main.cpp:35: error: variable or field `OnAbout' declared void
main.cpp:35: error: `int MyFrame::OnAbout' is not a static member of `class MyFrame'
main.cpp:35: error: `wxCommandEvent' was not declared in this scope
main.cpp:35: error: `event' was not declared in this scope
main.cpp:36: error: expected `,' or `;' before '{' token
Process terminated with status 1 (0 minutes, 0 seconds)
25 errors, 0 warnings

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Installed but can't compile
« Reply #7 on: August 15, 2005, 03:31:48 pm »
app.h:4:23: wx/wxprec.h: No such file or directory
app.h:11:23: wx/wx.h: No such file or directory

Are you sure to have specified correctly all the INCLUDE directories? The compiler cannot find the .h files. Try to look if the necessary INCLUDE directories are set correctly and in the correct location.

Best wishes,
Michael

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: Installed but can't compile
« Reply #8 on: August 15, 2005, 03:44:17 pm »
Have You added <wx-dir>/lib/mswdll into Your include directories (there's setup.h file which MUST be available somewhere in include paths)

jsimmons

  • Guest
Re: Installed but can't compile
« Reply #9 on: August 15, 2005, 04:16:34 pm »
app.h:4:23: wx/wxprec.h: No such file or directory
app.h:11:23: wx/wx.h: No such file or directory

Are you sure to have specified correctly all the INCLUDE directories? The compiler cannot find the .h files. Try to look if the necessary INCLUDE directories are set correctly and in the correct location.

Best wishes,
Michael

Well, I assume that if I create the app with the IDE, it should pretty much be able to find the files, especially if it asks me where to put them when I created the new project. :)

Do I have to include the project directory in the include path?



jsimmons

  • Guest
Re: Installed but can't compile
« Reply #10 on: August 15, 2005, 04:24:32 pm »
Have You added <wx-dir>/lib/mswdll into Your include directories (there's setup.h file which MUST be available somewhere in include paths)

Well, I started looking around in my CB install, and can't find wx anywhere, despite being told this:

Quote
By the way... RC1-1 comes with wx2.4 rather than wx2.6

My impression from that statement was that wx 2.4  is included with the install, and I suspect now that it's not.  So I'm off to download 2.42...

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: Installed but can't compile
« Reply #11 on: August 15, 2005, 05:26:19 pm »
Well, I assume that if I create the app with the IDE, it should pretty much be able to find the files, especially if it asks me where to put them when I created the new project.
---------------------------------------------------------------------------------------------------------------------------------------------------------

Yes, I would have done the same assumption :), but similar experiences with other IDEs free or not have made me more carefully. Therefore in case of problems, I always check if the setting options are correctly.

For example, I have played a bit with CB and Qt 4. CB generated a project template, but it did not compile. Sure thing, as I did and do not have Qt 4 installed in my computer (just Qt 3).

I think that you have to check if all the libraries you use have their include/lib directories set correctly (project directories eventually too) and in the correct location. For example, I would assume that if I want to use Qt with CB, I have to install it and then set the include/lib directories in CB together with some pre-processor instructions (even if CB can generate automatically a template Qt project).

Best wishes,
Michael

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: Installed but can't compile
« Reply #12 on: August 15, 2005, 05:44:03 pm »
My impression from that statement was that wx 2.4  is included with the install, and I suspect now that it's not.  So I'm off to download 2.42...

Yes, You have to download it, wxWidgets libraries are not supplied with C::B (only dll-s with binary version).

Installation step-by-step guide can be found inside wiki:

http://wiki.codeblocks.org/index.php/Tutorials

BTW. There are two important custom variables used inside C::B projects: WX_DIR and WX_CFG - these can help with directories

jsimmons

  • Guest
Re: Installed but can't compile
« Reply #13 on: August 15, 2005, 09:16:07 pm »
My impression from that statement was that wx 2.4  is included with the install, and I suspect now that it's not.  So I'm off to download 2.42...

Yes, You have to download it, wxWidgets libraries are not supplied with C::B (only dll-s with binary version).

Installation step-by-step guide can be found inside wiki:

http://wiki.codeblocks.org/index.php/Tutorials

BTW. There are two important custom variables used inside C::B projects: WX_DIR and WX_CFG - these can help with directories

That fixed it. I now have the program compiling.  Many thanks.  Now for the easy part - converting the 500,000 line MFC project over to wxWidgets... :)

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Installed but can't compile
« Reply #14 on: August 15, 2005, 09:47:19 pm »
Hint: Redesign it from scratch. If you're using so much MFC you might need to redesign it with a multi-tier approach sooner or later, anyway ;-)