How to set up wxWidgets 3.1.0 with Visual Studio 2

2019-01-23 21:45发布

I am somewhat of a beginner when it comes to open source libraries. I have tried to compile from source and use the pre-built binaries, but in both cases I get a ton of errors when I try to run the simple 'Hello World' program on the tutorial section of the wxWidgets website. After playing around for quite some time, the closest I have got to compiling is by building the libraries from source, but I still have 2 errors remaining:

  • "_w64 can only be specified on int, long, and pointer types" file: defs.h
  • "cannot open file 'wxbase31ud.lib" - LINK

It seems strange to me that the header file provided by wx would have an error such as that one, so I imagine both errors are because of something I am doing. I am hoping that someone here can do one of the following for me:

  1. Help me solve these errors
  2. Provide instructions for building libraries from source and subsequently linking my program to the correct directories

Some additional info: I am working on x64 Windows 7, my target will also be x64 exclusively. I do not have admin privileges, so no editing the system PATH for me.

Thanks for your help!

1条回答
看我几分像从前
2楼-- · 2019-01-23 22:10

The simplest way to start working with the library is this:

  1. Grab the sources.
  2. Unpack the sources.
  3. Open VS IDE.
  4. Open \build\msw\wx-vc14.sln (adjust as necessary.)
  5. Go to "Build->Batch Build...", click "Select All", "Build".
  6. Go drink some coffee or watch TV.
  7. After the build finishes, open wxWidgets/samples/minimal/minimal_vc9.sln.
  8. Let MSVC convert the solution to become an appropriate format.
  9. Build and run the sample.

If you will acquire any issue during those steps, let us know. The library build in step 5 should build without any issues and then all you will need is to build the minimal sample.

The next step is to copy the samples\minimal folder somewhere and start writing the code. All you will need to do is to change the Include and Lib search path.

[EDIT]

If you can build the 32-bit libraries (which are default in the provided solutions) all you will need is to convert them to be 64-bit and rebuild.

There is no changes to the $PATH or any environmental variable involved. Moreover you shouldn't build anything with the admin priviledges.

Also as Thomas pointed out you library build has to match whatever sample you are trying to build.

[/EDIT]

查看更多
登录 后发表回答