Trying to compile hello world example with visual studio 2017

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
nabz32x
Earned a small fee
Earned a small fee
Posts: 12
Joined: Wed Nov 28, 2018 12:09 pm

Trying to compile hello world example with visual studio 2017

Post by nabz32x »

Hello, I am trying to compile the hello world example
with VS 2017.

I have built the libraries using nmake with the VS2017 command prompt ( configuration static, release, x64 )
I then tried to build the minimal sample also with nmake, worked without problems.

But when I try to build the hello world from the visual studio IDE ( linker directories and include directories set properly ).
I get 86 errors and it won compile ( even the minimal sample project will not compile when using the IDE ).
(I also used the same configuration for those projects in the IDE as I used to build the libraries of wxWidgets ( Release x64 ).

Because I want to integrate this into an existing project, I would prefer to be able to compile it using the vs2017 IDE.
I searched a long time for a solution and now I am asking here.

Are there some additional preprocessor options I need to set? Or are there additional includes, libs needed?


Thanks in advance.

Edit: I am using version 3.0.4 ( latest stable ) but it appears that my setup.h is missing some defines, at least some errors tell me this,
but the comment tells me, that this can only happen if I happened to get partial releases with git or svn, which is not the case.

Edit2:
Those are the errors, all related to an inconsistend setup.h

Code: Select all

Schweregrad	Code	Beschreibung	Projekt	Datei	Zeile	Unterdrückungszustand
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_XML must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	290	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_XLOCALE must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	378	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_VARIANT must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	370	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_URL must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	362	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_TEXTFILE must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	346	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_TEXTBUFFER must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	338	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_STREAMS must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	322	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_STOPWATCH must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	330	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_STD_STRING_CONV_IN_WXSTRING must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	314	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_STD_CONTAINERS must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	306	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_STDPATHS must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	282	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_SOCKETS must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	298	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_REGEX must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	274	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_PROTOCOL must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	232	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_PRINTF_POS_PARAMS must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	224	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_ON_FATAL_EXCEPTION must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	216	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_MIMETYPE must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	208	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_LONGLONG must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	200	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_LOG must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	192	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_IPV6 must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	184	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_INTL must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	176	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_FS_ARCHIVE must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	144	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_FSWATCHER must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	160	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_FSVOLUME must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	152	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_FILE_HISTORY must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	128	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_FILESYSTEM must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	136	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_EXCEPTIONS must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	120	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_DYNLIB_CLASS must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	112	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_DYNAMIC_LOADER must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	168	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_CONSOLE_EVENTLOOP must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	104	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_COMPILER_TLS must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	96	
Fehler (aktiv)	E0035	#error-Direktive: "wxUSE_ANY must be defined, please read comment near the top of this file."	ConsoleApplication1	c:\Users\mweber\Downloads\wxWidgets304installed\include\wx\chkconf.h	88	

User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Trying to compile hello world example with visual studio 2017

Post by doublemax »

Start with the VS project files for the "minimal" sample. That should build out of the box.
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Trying to compile hello world example with visual studio 2017

Post by ONEEYEMAN »

Hi,
Did you build the libraries yourself or use precompiled ones?
Did you modify the setup.h in any way prior to building?

Also, you gave to copntradicting pieces of information - you said that minimal sample was building successfully and lkater said that minimal sample was not built. Which one is it?

Thank you.
nabz32x
Earned a small fee
Earned a small fee
Posts: 12
Joined: Wed Nov 28, 2018 12:09 pm

Re: Trying to compile hello world example with visual studio 2017

Post by nabz32x »

ONEEYEMAN wrote:Hi,
Did you build the libraries yourself or use precompiled ones?
Did you modify the setup.h in any way prior to building?

Also, you gave to copntradicting pieces of information - you said that minimal sample was building successfully and lkater said that minimal sample was not built. Which one is it?
Zitat doublemax
It did build the minimal sample succesfully using nmake via the visual studio command prompt,
but it is giving me those errors when trying to compile the project in the visual studio IDE.

I build the libraries using nmake and i have not altered the setup.h

Edit: I am trying again to compile the libraries using the visual studio 2017 IDE now, maybe this helps
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: Trying to compile hello world example with visual studio 2017

Post by PB »

Sorry for the stupid question but did you do what the error message says, i.e., read the file? It says
If you get an error saying "wxUSE_FOO must be defined", it means that you
are not using the correct up-to-date version of setup.h. This happens most
often when using git or snapshots and a new symbol was added to setup0.h
and you haven't updated your local setup.h to reflect it. If this is the
case, you need to propagate the changes from setup0.h to your setup.h and,
if using makefiles under MSW, also remove setup.h under the build directory
(lib/$(COMPILER)_{lib,dll}/msw[d][dll]/wx) so that the new setup.h is
copied there.

Are you sure the above is not the root of your issue, i.e., setup.h in WXWIN\include\msw and the build-specific one (e.g. in WXWIN\Lib\wxWidgets-GIT\lib\vc_x64_lib\mswud\wx are the same as WXWIN\include\msw\setup0.h?

How exactly did you build wxWidgets (the command line)?

What wxWidgets-related settings do you have in your project (assuming Unicode Debug Static build) in:
  • preprocessor settings,
  • compiler additional include directories,
  • linker additional library directories,
  • linker additional dependencies.


Adding wxWidgets to an MSVC project is super easy, all one has to do is follow the simple instructions in the section Building Applications Using wxWidgets here.
nabz32x
Earned a small fee
Earned a small fee
Posts: 12
Joined: Wed Nov 28, 2018 12:09 pm

Re: Trying to compile hello world example with visual studio 2017

Post by nabz32x »

I used the commands specified in the readme under docs/mws
for x64 release settings.

After deleting everything and building it again ( this time from the ide, using batch build ) .
Everything works now.

I think I didn do this before
"also remove setup.h under the build directory
(lib/$(COMPILER)_{lib,dll}/msw[d][dll]/wx) so that the new setup.h is
copied there." Didnt read that long, because I thought the preamble leading to this section was
not fitting my case.
But now it worked without doing so when building using the visual studio ide directly.

I am now going to replace that ugly fltk with wxwidgets,
thanks for your answers.
alankdkd
In need of some credit
In need of some credit
Posts: 5
Joined: Mon Feb 04, 2019 6:33 pm

Re: Trying to compile hello world example with visual studio 2017

Post by alankdkd »

"If you get an error saying "wxUSE_FOO must be defined", it means that you
are not using the correct up-to-date version of setup.h. This happens most
often when using svn or daily snapshots and a new symbol was added to
setup0.h and you haven't updated your local setup.h to reflect it. If
this is the case, you need to propagate the changes from setup0.h to your
setup.h and, if using makefiles under MSW, also remove setup.h under the
build directory (lib/$(COMPILER)_{lib,dll}/msw[d][dll]/wx) so that
the new setup.h is copied there."


There IS NO setup0.h!!! I've installed wxWidgets 3.0.4 and this file doesn't exist.
I'm getting lots of "wxUSE_FOO must be defined" errors.

I removed setup.h, as described, and just get more compile errors. This product is very difficult to use, and the documentation isn't clear.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Trying to compile hello world example with visual studio 2017

Post by ONEEYEMAN »

Hi,
Please start from the clean system.
1. Download the archive wxWidgets-3.1.3.
2. Unpack the archive to some directory, e.g. c:\wxWidgets-3.1.3
3. Start MSVS.
4. In the IDE
4a File->Open, then navigate to c:\wxWidgets-3.1.3\build\msw
4b. Open the file wx_vc<n>.sln
4c. Build->Batch Build
4d. Build All

Let us know if you still can't build after following this simple set of instructions.

After the build finishes, do the following (still inside the IDE):

5. File->Open
6. Navigate to c:\wxWidgets-3.1.3\samples\minimal
7. Open the sln/dsw that correspond to the VS version you have.
8. Build the solution
9. Run the solution.

Let us know if you have any issue following this simple set of instructions.

At any point of time do not delete any file. If you get an error, please post the full error message and the version of MSVS you are using.

Thank you.
alankdkd
In need of some credit
In need of some credit
Posts: 5
Joined: Mon Feb 04, 2019 6:33 pm

Re: Trying to compile hello world example with visual studio 2017

Post by alankdkd »

ONEEYEMAN: Thanks for the fast reply! I'll try your suggestions. :D
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: Trying to compile hello world example with visual studio 2017

Post by PB »

I believe that oneeyeman meant version 3.1.2: 3.1.3 is current GIT master, still unreleased (but usable).

Anyway, 3.1.2 has a major advantage over 3.0.x: it has better documentation for MSVC as well as one more easy way to add wxWidgets to your project, see e.g. here: http://wxwidgets.org/blog/2018/11/using ... with-msvs/.

I still use the msvc-specific setup.h which makes things easy. I also believe that the best documentation is the official one, provided for wxWidgets 3.1.2 in %WXWIN%/docs/msw/install.md file.

BTW, setup0.h you mentioned in your previsou post is not distributed as a part of a wxWidgets release downloadable from the web site, the file is present only when you get the sources from GitHub.
Post Reply