README.MSWindows.txt 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. README.MSWindows.txt - Building FLTK under Microsoft Windows
  2. --------------------------------------------------------------
  3. CONTENTS
  4. ==========
  5. 1 INTRODUCTION
  6. 2 HOW TO BUILD FLTK USING MinGW/Cygwin
  7. 2.1 The Tools
  8. 2.2 Recommended Command Line Build Environment
  9. 2.3 Prerequisites
  10. 2.4 Downloading and Unpacking
  11. 2.5 Configuring FLTK
  12. 2.6 Building FLTK
  13. 2.7 Testing FLTK
  14. 2.8 Installing FLTK
  15. 2.9 Creating new Projects
  16. 3 HOW TO BUILD FLTK USING VISUAL STUDIO 2008
  17. 3.1 Prerequisites
  18. 3.2 Downloading and Unpacking
  19. 3.3 Configuring FLTK
  20. 3.4 Building FLTK
  21. 3.5 Testing FLTK
  22. 3.6 Installing FLTK
  23. 3.7 Creating new Projects
  24. 4 HOW TO BUILD FLTK USING VISUAL STUDIO 2010 OR LATER
  25. 4.1 Prerequisites
  26. 4.2 Downloading and Unpacking
  27. 4.3 Configuring FLTK
  28. 4.4 Building FLTK
  29. 4.5 Testing FLTK
  30. 4.6 Installing FLTK
  31. 4.7 Creating new Projects
  32. 5 FREQUENTLY ASKED QUESTIONS
  33. 7 LINKS
  34. 6 DOCUMENT HISTORY
  35. INTRODUCTION
  36. ==============
  37. FLTK 1.3 and later is officially supported on Windows (2000,) 2003,
  38. XP, and later. Older Windows versions are not officially supported,
  39. but may still work. The main reason is that the OS version needs
  40. to support UTF-8. FLTK 1.3 is known to work on Windows Vista, Windows 7,
  41. Windows 8/8.1, and Windows 10.
  42. FLTK currently supports the following development
  43. environments on the Windows platform:
  44. - Free Microsoft "Visual C++ 2008 Express" or later or "Visual Studio
  45. Community 2013" or later. The Visual Studio project files must be
  46. generated using CMake. Visual Studio 2017 includes CMake support:
  47. "Visual Studio 2017 introduces built-in support for handling CMake
  48. projects. This makes it a lot simpler to develop C++ projects built
  49. with CMake without the need to generate VS projects and solutions
  50. from the command line. This post gives you an overview of the CMake
  51. support, how to easily get started and stay productive in Visual Studio."
  52. Citation from:
  53. https://blogs.msdn.microsoft.com/vcblog/2016/10/05/cmake-support-in-visual-studio/
  54. As of this writing (07/2017) the FLTK team did not yet test and
  55. verify the functionality of Microsoft's included CMake features.
  56. - GNU toolsets (Cygwin or MinGW) hosted on Windows.
  57. CAUTION: Libraries built by any one of these environments can not be mixed
  58. with object files from any other environment!
  59. HOW TO BUILD FLTK USING MinGW and Cygwin
  60. ==========================================
  61. This chapter of this document gives a brief overview of
  62. compiling and using FLTK with the Cygwin and MinGW compiler
  63. toolkits. Both toolkits provide a build environment based
  64. around the GNU C/C++ compiler. Further information is
  65. available from the FLTK website at http://www.fltk.org, such
  66. as this Howto note: http://www.fltk.org/articles.php?L598
  67. The Cygwin build environment supplies a library (the Cygwin
  68. DLL) that is primarily intended to provide a number of
  69. Unix-like POSIX facilities for programs being ported to the
  70. Windows environment (Win32 or WinNT). Cygwin also supplies
  71. a very Unix-like build environment for Windows, including
  72. the "BASH" Bourne-compatible shell and all of the standard
  73. Unix file utilities (ls, cat, grep, etc.).
  74. Cygwin is developed by Cygnus (now part of RedHat, Inc).
  75. Although provided for free download under the GPL, distributing
  76. programs that require the Cygwin DLL under a license other than
  77. the GPL requires a commercial license for the Cygwin DLL.
  78. Native Windows programs that do not require the Cygwin DLL
  79. (cross-compiled and linked with the MinGW gcc/g++ cross compilers
  80. supplied with Cygwin) may be released under any license freely.
  81. Currently you would have to install mingw64-i686-gcc-g++ for
  82. 32-bit Windows applications (despite its name!), and/or
  83. mingw64-x86_64-gcc-g++ for 64-bit applications. You may also
  84. need to install the corresponding '-headers' packages as well.
  85. Currently these tools support gcc 4.5 or newer. The setup for
  86. FLTK is somewhat more complicated because you must configure
  87. this as a cross compiler, but it works well.
  88. The MinGW distribution (Minimalist GNU for Windows) provides
  89. a similar toolset but geared solely towards native Windows
  90. development without the Unix-like POSIX library. The lack of
  91. any libraries under the GPL or any other restrictive license
  92. means that programs built with the MinGW environment may
  93. always be released under any license freely. MinGW also
  94. supplies a Unix-like build environment for Windows,
  95. including MSYS (a Bourne-compatible shell) and the standard
  96. Unix file utilities (ls, cat, grep, etc.)
  97. If you are not familiar with these GNU-like toolkits please
  98. refer to the links section later in this note. In particular,
  99. check out their license conditions carefully before use.
  100. The Tools
  101. -----------
  102. There are currently three main configurations supported by
  103. FLTK with the GNU tools:
  104. 1. Cygwin: Built using the Cygwin toolset and using the Unix-like
  105. POSIX compatibility layer provided by the Cygwin DLL.
  106. License: GPL or non-free commercial license (ask Redhat).
  107. 2. Cygwin using the MinGW cross compiler suite: Built using
  108. the Cygwin tools but not using the Cygwin DLL.
  109. License: freely distributable on all Windows systems.
  110. 3. MinGW: Built using the MinGW utilities, compiler and tools. This
  111. is, in many aspects, analogous to (2.). This is the recommended
  112. one if you want to build native Windows programs only.
  113. License: freely distributable on all Windows systems.
  114. Recommended Command Line Build Environment
  115. --------------------------------------------
  116. Our recommendation is to:
  117. 1. Get the current Cygwin toolset.
  118. This can either produce executables that do or do not
  119. rely on the Cygwin DLL (check licensing) at your choice.
  120. 2. Get the latest MinGW toolset. It is recommended that you
  121. also get the MSYS shell and the msysDTK developer toolset.
  122. This will only produce normal Windows native executables
  123. without any Unix or POSIX compatibility layer.
  124. See the links section below for more information.
  125. Either option can generate Windows native executables and option 1 can
  126. provide a Unix-like POSIX portability layer that is reliant on a GPLed library.
  127. See the later sections for detailed information about using
  128. one of these configurations.
  129. Prerequisites
  130. ---------------
  131. In order to build FLTK from the command line, you need to install the MinGW
  132. environment from www.mingw.org. The graphical installer "mingw-get-inst" can
  133. be downloaded here for free:
  134. http://www.mingw.org/wiki/Getting_Started
  135. Launch the installer and follow the instructions. In the "Select Components"
  136. dialog, add "C++ Compiler", "MSYS Basic System", and "MinGW Developer Toolkit".
  137. Wait for the installer to finish.
  138. After downloading and installing, you need to launch the MinGW Shell through
  139. the Start menu.
  140. Downloading and Unpacking
  141. ---------------------------
  142. Download FLTK from here:
  143. http://www.fltk.org/software.php
  144. into your home folder. The default location as seen from MSWindows is similar
  145. to
  146. C:\MinGW\msys\1.0\home\matt\
  147. If you are familiar with "subversion" and like to stay current with your
  148. version, you will find the subversion access parameters at the bottom of
  149. that page. Unpack FLTK into a convenient location. I like to have everything
  150. in my dev directory:
  151. cd
  152. mkdir dev
  153. cd dev
  154. tar xvfz fltk-1.3.xxxx.tar.gz
  155. cd fltk-1.3.xxxx
  156. Configuring FLTK
  157. ------------------
  158. If you got FLTK via subversion then you need one extra step. Otherwise skip
  159. over this part. Stay in your FLTK source-code directory and type the
  160. following:
  161. NOCONFIGURE=1 ./autogen.sh
  162. Now configure your FLTK installation:
  163. ./configure
  164. ADVANCED: type "./configure --help" to get a complete list of optional
  165. configuration parameters. These should be pretty self-explanatory. Some
  166. more details can be found in README.
  167. :END_ADVANCED
  168. The configuration script will check your machine for the required resources
  169. which should all have been part of your MinGW installation. Review the
  170. Configuration Summary, maybe take some notes.
  171. ADVANCED: some versions of MinGW/Msys are broken and complain about a missing
  172. --enable-auto-import. The solution is to upgrade to the current release. If
  173. that is not possible, you can include the --enable-auto-import flag when
  174. linking:
  175. ./configure <config flags> LDFLAGS=-Wl,--enable-auto-import
  176. :END_ADVANCED
  177. Known Problems:
  178. There is a known incompatibility with some Windows subversion tools that
  179. may not set the correct line endings for autoconf. If you get strange
  180. error messages when running ./configure or make, you may need to convert
  181. configh.in to "Unix line endings" (LF-only). These error messages are
  182. unspecific, e.g. compilation errors like:
  183. error: 'U32' does not name a type
  184. error: 'bmibuffer' was not declared in this scope
  185. You can fix the line endings with the MinGW/msys tool 'unix2dos' (u2d)
  186. or with your favorite editor, if it allows to change the line endings,
  187. then run autoconf and ./configure again.
  188. For further information see this bug report:
  189. http://www.fltk.org/newsgroups.php?gfltk.bugs+v:10197
  190. Building FLTK
  191. ---------------
  192. Now this is easy. Stay in your FLTK source-code directory and type:
  193. make
  194. The entire FLTK toolkit including many test programs will be built for you.
  195. No warnings should appear.
  196. Testing FLTK
  197. --------------
  198. After a successful build, you can test FLTK's capabilities:
  199. test/demo
  200. Installing FLTK
  201. -----------------
  202. If you did not change any of the configuration settings, FLTK will be
  203. installed in "/usr/local/include" and "/usr/local/lib" by typing
  204. make install
  205. It is possible to install FLTK in user space by changing the installation path
  206. to a location within the user account by adding the "--prefix=PREFIX" parameter
  207. to the "./configure" command.
  208. Creating new Projects
  209. -----------------------
  210. FLTK provides a neat script named "fltk-config" that can provide all the flags
  211. needed to build FLTK applications using the same flags that were used to build
  212. the library itself. Running "fltk-config" without arguments will print a list
  213. of options. The easiest call to compile an FLTK application from a single
  214. source file is:
  215. fltk-config --compile myProgram.cxx
  216. "fltk-config" and "fluid" will be installed in "/usr/local/bin/" by default.
  217. I recommend that you add it to the command search path.
  218. HOW TO BUILD FLTK USING MICROSOFT VISUAL STUDIO
  219. ================================================
  220. Prerequisites
  221. ---------------
  222. In order to build FLTK from within Visual Studio, you need to install the
  223. Visual C++ developer environment from the Microsoft web site. The "Express"
  224. or "Community" edition is free of charge and sufficient to develop FLTK
  225. applications:
  226. https://www.visualstudio.com/vs/visual-studio-express/
  227. If you intend to use an older (maybe commercial) version you need at least
  228. a version that is supported by the version of CMake you are using to generate
  229. the project files. You should make sure that all available service packs are
  230. installed or building FLTK may fail.
  231. As of this writing (07/2017) the FLTK team recommends at least Visual
  232. Studio 2008 with current service packs. Visual Studio 2008, 2010, 2013,
  233. 2015, and 2017 are known to work with FLTK 1.4.0 (svn, 07/2017).
  234. You also need to install CMake (cmake-gui) from:
  235. https://cmake.org/download/
  236. Visual Studio 2017 has internal CMake support (so you may not need to
  237. install CMake separately), but this has not yet been tested thoroughly
  238. by the FLTK team.
  239. Downloading and Unpacking FLTK
  240. --------------------------------
  241. Download FLTK from here:
  242. http://www.fltk.org/software.php
  243. If you are familiar with "subversion" and like to stay current with your
  244. version, you will find the subversion access parameters at the bottom of
  245. that page.
  246. Unpack FLTK by using an appropriate unpacker and copy the new folder into a
  247. convenient location. I have set up a "dev" folder in my home folder for all
  248. my projects.
  249. Configuring FLTK
  250. ------------------
  251. Note: Configuration with Visual Studio 2017's internal CMake support is
  252. not yet included here. You may try yourself...
  253. Please refer to README.CMake.txt for how to configure FLTK with CMake.
  254. Once you have followed the instructions you should have created a new
  255. build directory with the Visual Studio Solution (project files) for FLTK.
  256. Launch Visual Studio and open the project file (FLTK.sln) or double-click
  257. on FLTK.sln in the Windows Explorer.
  258. Choose "Debug" or "Release" mode from the "Solution Configurations" menu.
  259. Building FLTK
  260. ---------------
  261. Use the context menu of the "demo" project to "Set as StartUp Project". Then
  262. select "Build Solution" from the "Build" menu or press F7 to build all
  263. libraries.
  264. Testing FLTK
  265. --------------
  266. Select "Start Debugging" from the "Debug" menu or just press F5 to run the
  267. Demo program. Use "Demo" to explore all test programs.
  268. Installing FLTK
  269. -----------------
  270. ********************************************************************************
  271. The information in this chapter is NO LONGER RECOMMENDED by the FLTK team.
  272. ********************************************************************************
  273. The default location for VisualC 2008 libraries and headers is here:
  274. C:\Program Files\Microsoft Visual Studio 9.0\VC\
  275. It is possible to move the FLTK libraries, headers, and Fluid into the
  276. respective subdirectories, so that they are available for future development
  277. without adding link and include paths to the solution.
  278. copy the entire FL directory into the include path
  279. add all files from ide\VisualC2008\FL to the FL directory copied above
  280. (this is currently only one file: abi-version.h)
  281. copy all .lib files from the fltk lib directory to the VC lib directory
  282. copy fluid.exe in the fluid directory to the bin directory
  283. I highly discourage using dll's (dynamically linking libraries) on MSWindows
  284. because they will require an installation process and likely cause version
  285. conflicts. Use the static .lib libraries instead.
  286. Creating new Projects
  287. -----------------------
  288. ********************************************************************************
  289. The information in this chapter is NO LONGER RECOMMENDED by the FLTK team.
  290. ********************************************************************************
  291. This chapter assumes that libraries and headers were copied into
  292. C:\Program Files\Microsoft Visual Studio 9.0\VC\
  293. Create a new project of type "General", "Empty Project" and add a simple "C++"
  294. file to it. The FLTK "hello" source code is a good base.
  295. Now open the Project Properties dialog and add "Comctl32.lib" and all the FLTK
  296. libraries that you want to use (at least "fltk.lib") to Additional Dependencies
  297. (Configuration Properties > Linker > Additional Dependencies). In the same
  298. dialog, add "WIN32" to the C++ Preprocessor Definitions (Configuration
  299. Properties > C/C++ > Preprocessor > Preprocessor Definitions).
  300. Compile and run your test program with F5.
  301. You can also include .fl resources: add a new Header file to your project, but
  302. let the name end in .fl. Right-click and select "Open with...". Add "fluid.exe"
  303. from the "bin" directory and set it as the default editor.
  304. To automatically compile .fl files, open the Properties editor and set the
  305. Custom Build Steps to:
  306. Command Line: fluid.exe -c $(InputPath)
  307. Description: Compiling Fluid .fl file
  308. Outputs: $(InputDir)$(InputName).cxx; $(InputDir)$(InputName).h
  309. Now add the generated .cxx file to your project as well. Whenever the .fl file
  310. is changed, the corresponding .cxx file will be recompiled.
  311. HOW TO BUILD FLTK USING VISUAL STUDIO 2010 OR LATER
  312. ====================================================
  313. Prerequisites
  314. ---------------
  315. See previous chapter "HOW TO BUILD FLTK USING MICROSOFT VISUAL STUDIO".
  316. Downloading and Unpacking
  317. ---------------------------
  318. See previous chapter "HOW TO BUILD FLTK USING MICROSOFT VISUAL STUDIO".
  319. Configuring FLTK
  320. ------------------
  321. See previous chapter "HOW TO BUILD FLTK USING MICROSOFT VISUAL STUDIO".
  322. Building FLTK
  323. ---------------
  324. See previous chapter "HOW TO BUILD FLTK USING MICROSOFT VISUAL STUDIO".
  325. Testing FLTK
  326. --------------
  327. See previous chapter "HOW TO BUILD FLTK USING MICROSOFT VISUAL STUDIO".
  328. Installing FLTK
  329. -----------------
  330. ********************************************************************************
  331. The information in this chapter is NO LONGER RECOMMENDED by the FLTK team.
  332. ********************************************************************************
  333. The default location for VisualC 2010 libraries and headers is here:
  334. C:\Program Files\Microsoft Visual Studio 10.0\VC\
  335. It is possible to move the FLTK libraries, headers, and Fluid into the
  336. respective subdirectories, so that they are available for future development
  337. without adding link and include paths to the solution.
  338. copy the entire FL directory into the include path
  339. add all files from ide\VisualC2010\FL to the FL directory copied above
  340. (this is currently only one file: abi-version.h)
  341. copy all .lib files from the fltk lib directory to the VC lib directory
  342. copy fluid.exe in the fluid directory to the bin directory
  343. I highly discourage using dll's (dynamically linking libraries) on MSWindows
  344. because they will require an installation process and likely cause version
  345. conflicts. Use the static .lib libraries instead.
  346. Creating new Projects
  347. -----------------------
  348. ********************************************************************************
  349. The information in this chapter is NO LONGER RECOMMENDED by the FLTK team.
  350. ********************************************************************************
  351. This chapter assumes that libraries and headers are copied into
  352. C:\Program Files\Microsoft Visual Studio 10.0\VC\
  353. Create a new project of type "General", "Empty Project" and add a simple "C++"
  354. file to it. The FLTK "hello" source code is a good base.
  355. Now open the Project Properties dialog and add "Comctl32.lib" and all the FLTK
  356. libraries that you want to use (at least "fltk.lib") to Additional Dependencies
  357. (Configuration Properties > Linker > Additional Dependencies). In the same
  358. dialog, add "WIN32" to the C++ Preprocessor Definitions (Configuration
  359. Properties > C/C++ > Preprocessor > Preprocessor Definitions).
  360. Compile and run your test program with F5.
  361. You can also include .fl resources: add a new Header file to your project, but
  362. let the name end in .fl. Right-click and select "Open with...". Add "fluid.exe"
  363. from the "bin" directory and set it as the default editor.
  364. To automatically compile .fl files, open the Properties editor and change the
  365. Element Type to Custom Build and click Apply. Now set the
  366. Custom Build Steps to:
  367. Command Line: fluid.exe -c %(FullPath)
  368. Description: Compiling Fluid .fl file
  369. Outputs: $(InputDir)$(InputName).cxx; $(InputDir)$(InputName).h
  370. Now add the generated .cxx file to your project as well. Whenever the .fl file
  371. is changed, the corresponding .cxx file will be recompiled.
  372. FREQUENTLY ASKED QUESTIONS
  373. ============================
  374. Why does a console window appear when I run my program?
  375. ---------------------------------------------------------
  376. Windows has a flag that determines whether an application
  377. runs in the foreground with a console or in the background
  378. without a console.
  379. If you're using gcc (i.e. MinGW or Cygwin), then use the
  380. linker option "-mwindows" to make your application run in
  381. the background and "-mconsole" to run in the foreground. Use
  382. fltk-config --ldflags to see appropriate linker flags, or use
  383. fltk-config --compile to compile a single source file.
  384. If you're using MS VC++, then you must set the linker option
  385. "/subsystem:windows" to create a "Windows" program (w/o console
  386. window), or set the linker option "/subsystem:console" for a
  387. console program, i.e. with a console window. These options
  388. are set differently in the FLTK project files, depending on
  389. whether you select a "Debug" or "Release" build.
  390. Other compilers and build systems may have different options.
  391. Keep in mind that a windows application cannot send output
  392. to stdout, even if you run it from an existing console
  393. application.
  394. (Note: A special case of this exists if running a MinGW
  395. application from the command line of an MSYS shell, when an
  396. application is able to write to stdout, even if compiled with
  397. "-mwindows". The same applies to Cygwin.)
  398. How do I get OpenGL to work?
  399. ------------------------------
  400. Both builds should automatically support OpenGL.
  401. The configuration file config.h has a number of settings
  402. which control compile-time compilation. One such setting is
  403. "HAVE_GL". This may be set to 0 to disable Open GL operation.
  404. Changing the line in config.h to
  405. #define HAVE_GL 1
  406. will change this to compile and link in OpenGL.
  407. LINKS
  408. =======
  409. The following links may be of use:
  410. 1. Main Cygwin homepage:
  411. http://www.cygwin.com/
  412. 2. Main MinGW homepage:
  413. http://www.mingw.org/
  414. In particular look for the MinGW FAQ at this link for
  415. a lot of useful Mingw-native development documentation.
  416. 3. Check out the FLTK newsgroups at the FLTK homepage:
  417. http://www.fltk.org/
  418. Its archival search facilities are EXTREMELY useful
  419. to check back through previous problems with this
  420. sort of configuration before posting new questions.
  421. 4. GNU Compiler Collection (GCC) compiler homepage:
  422. http://gcc.gnu.org/
  423. 5. OpenGL page - for OpenGL and GLUT libs
  424. http://www.opengl.org/
  425. 6. CMake homepage:
  426. https://cmake.org/
  427. DOCUMENT HISTORY
  428. ==================
  429. Oct 25 2010 - matt: restructured entire document and verified instructions
  430. Dec 20 2010 - matt: merged with README.win32
  431. Dec 22 2010 - Albrecht: added newer Cygwin (cross/mingw-w64) options
  432. Feb 24 2012 - Albrecht: clarified console window FAQ
  433. Jul 05 2017 - Albrecht: several updates, particularly on Visual Studio usage