static linking for Windows + MinGW-w64(MSYS2) + Eclipse

41 views
Skip to first unread message

anonymous

unread,
Sep 23, 2020, 6:11:32 AM9/23/20
to fltk.general

Hello,

I'm trying to build a hello.cxx code(sample code in the FLTK doc) using Eclipse, with MSYS2 packages mingw-w64-x86_64-toolchain and mingw-w64-x86_64-fltk.
Looks like linking comctl32 library does not work properly. Here's the log:

Info: Internal Builder is used for build
g++ -static -o hello.exe "src\\hello.o" -lcomctl32 -lfltk -lgdi32 -lole32 -luuid
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libfltk.a(Fl.o):(.text$_ZL7WndProcP6HWND__jyx+0x41a): undefined reference to `__imp__TrackMouseEvent'
collect2.exe: error: ld returned 1 exit status

I have no idea why this error occur even I link the comctl32 library. Could anyone give an advice for this?

PS. Is there any way to use fltk-config script in Eclipse? The IDE simply could not find the script if I manually add it using Linker flags.

Albrecht Schlosser

unread,
Sep 23, 2020, 6:14:53 AM9/23/20
to fltkg...@googlegroups.com
On 9/23/20 12:01 PM anonymous wrote:
>
> I'm trying to build a hello.cxx code(sample code in the FLTK doc) using
> Eclipse, with MSYS2 packages mingw-w64-x86_64-toolchain and
> mingw-w64-x86_64-fltk.
> Looks like linking comctl32 library does not work properly. Here's the log:
>
> Info: Internal Builder is used for build
> g++ -static -o hello.exe "src\\hello.o" -lcomctl32 -lfltk -lgdi32
> -lole32 -luuid
> C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
> C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libfltk.a(Fl.o):(.text$_ZL7WndProcP6HWND__jyx+0x41a):
> undefined reference to `__imp__TrackMouseEvent'
> collect2.exe: error: ld returned 1 exit status
>
> I have no idea why this error occur even I link the comctl32 library.
> Could anyone give an advice for this?

Try to change the linking order, put -lcomctl32 after -lfltk, i.e. where
the other Windows libs are in your commandline.

> PS. Is there any way to use fltk-config script in Eclipse? The IDE
> simply could not find the script if I manually add it using Linker flags.

Sorry, no idea.

anonymous

unread,
Sep 23, 2020, 7:47:48 AM9/23/20
to fltk.general
>Try to change the linking order, put -lcomctl32 after -lfltk, i.e. where
>the other Windows libs are in your commandline

Thanks for your answer. It works without any problem.
About the fltk-config, I'd better just try it with Makefile.

Ian MacArthur

unread,
Sep 23, 2020, 3:47:14 PM9/23/20
to fltkg...@googlegroups.com
FWIW, with Eclipse I *really* do not like the way it sets up projects, so I always use my own Makefiles anyway, which (to be fair) Eclipse is fine with. It also means I can use fltk-config for a lot of stuff as it is easy to call fltk-config from a Makefile...

https://www.fltk.org/articles.php?L599



anonymous

unread,
Sep 23, 2020, 10:44:30 PM9/23/20
to fltk.general
FWIW, with Eclipse I *really* do not like the way it sets up projects, so I always use my own Makefiles anyway, which (to be fair) Eclipse is fine with. It also means I can use fltk-config for a lot of stuff as it is easy to call fltk-config from a Makefile...

https://www.fltk.org/articles.php?L599
I actually don't really like Eclipse neither, especially its intricate initial process. But sometimes, aside from Visual Studio, I think there's not really many good IDE for C++, even though CDT is not really ideal.

Albrecht Schlosser

unread,
Sep 23, 2020, 10:56:59 PM9/23/20
to fltkg...@googlegroups.com
On 9/24/20 3:59 AM anonymous wrote:

> I actually don't really like Eclipse neither, especially its intricate
> initial process. But sometimes, aside from Visual Studio, I think
> there's not really many good IDE for C++, even though CDT is not really
> ideal.

I had good experiences with the CodeLite IDE on Windows and Linux,
although it took some time to set it up initially for FLTK or any other
project. CMake is able to generate CodeLite IDE files, although the
result from FLTK's CMake files is suboptimal. But it works.

Meanwhile I switched to Visual Studio Code (VS Code) by Microsoft (open
source on GitHub) which is also cross platform and works really like an
IDE in many aspects.

You can use a build environment generated by CMake (I'm using CMake, but
you can also use Makefiles) to build and test with a really good visual
(GUI) debugger interface.

I'm really impressed how well this works but I tested so far only on
Linux. The Windows version should certainly work fine as well I think
(after all it's mainly developed by Microsoft).

Just my 2 ct.

anonymous

unread,
Sep 24, 2020, 1:19:27 AM9/24/20
to fltk.general
I had good experiences with the CodeLite IDE on Windows and Linux,
although it took some time to set it up initially for FLTK or any other
project. CMake is able to generate CodeLite IDE files, although the
result from FLTK's CMake files is suboptimal. But it works.

Meanwhile I switched to Visual Studio Code (VS Code) by Microsoft (open
source on GitHub) which is also cross platform and works really like an
IDE in many aspects.

You can use a build environment generated by CMake (I'm using CMake, but
you can also use Makefiles) to build and test with a really good visual
(GUI) debugger interface.

I'm really impressed how well this works but I tested so far only on
Linux. The Windows version should certainly work fine as well I think
(after all it's mainly developed by Microsoft).

Just my 2 ct.
While I have no experience with CodeLite,  I use Visual Studio Code like vi on Windows. It also works well with my (VERY)tiny project, nevertheless, I can hardly say it as an IDE. For me, it looks like an Emacs from Microsoft. Still needs some hassle for project settings.
Come to think of it, more of the projects are done with source-code editors. The heavy(and tricky) IDE might not really necessary. After all, I'll try Makefile so use of VSCode might worth it.

Thanks for your advice.
Reply all
Reply to author
Forward
0 new messages