OMS
OMS

Reputation: 55

wxWidgets with MinGW, "wx/wx.h: No such file or directory"

I am new to C++ and wxWidgets. During the last couple of days, I have followed a tutorial with Visual Studio into how to build wxWidgets desktop applications (https://www.youtube.com/watch?v=FOIbK4bJKS8&t=800s).

Now, because I am not familiar with Visual Studio, I wanted to move to edit the code with Atom and compile with MinGW from Windows command prompt.

The app has the following files:

cMake.h
AnalogRead.h
cMake.cpp
AnalogRead.cpp

In Visual Studio, you need to include two directories and one library in the project, which are the following: Paths:

/wxWidgets/include
/wxWidgets/include/msvc

Libraries:

/wxWidgets/lib/vc_lib

Relative to the path where the the C++ code is.

So I have tried to create the compile line, without success:

c++ -I/wxWidgets/include -I/wxWidgets/include/msvc -L/wxWidgets/lib/vc_lib cMake.cpp AnalogRead.cpp -o test

But I get the following error:

In file included from AnalogRead.cpp:1:0:
AnalogRead.h:3:19: fatal error: wx/wx.h: No such file or directory
 #include <wx/wx.h>
                   ^
compilation terminated.

The thing is, I am including that path in the compilation. wx/wx.h is inside the path /wxWidgets/include/.

Is there a way to fix this? Thanks in advance.

Upvotes: 0

Views: 3804

Answers (3)

VZ.
VZ.

Reputation: 22688

You can't compile the library with one compiler and then compile the application using it with another, this is just not going to work. You should decide which compiler you want to use (or maybe try using both of them, but not both at the same time!) and follow the official build instructions in the file docs/msw/install.md.

Upvotes: 2

Igor
Igor

Reputation: 6255

If you want to use MinGW, you need to build the library with MinGW compiler and then use EXACTLY THE SAME command to buid your software.

Or use an IDE (CodeBlocks, CodeLite).

HTH.

Upvotes: 2

3CxEZiVlQ
3CxEZiVlQ

Reputation: 38463

/wxWidgets/include is not a relative path. This is an absolute path in the current disk. Do you have C:\wxWidgets\include? Try -IwxWidgets/include or -I./wxWidgets/include, without the leading /. This path should work if you have the wxWidgets directory in your app sources.

Upvotes: 2

Related Questions