I have an "unrecognised emulation mode: windows" error from ld.exe. The procedure that lead up to it:
I compiled wxWdigets 3.1.2 using the command lines from http://wiki.codeblocks.org/index.php/WxWindowsQuickRef . Below is the Windows 7 batch file I created to do the compilations:
:: Build_wxWidgets
:: ref http://wiki.codeblocks.org/index.php/WxWindowsQuickRef
:: Compiler download:
:: https://sourceforge.net/projects/mingw-64/files/latest/download
cd C:\wxWidgets-3.1.2\build\msw
mingw32-make.exe -f makefile.gcc MONOLITHIC=0 RC=1 SHARED=1 UNICODE=1 USE_OPENGL=1 BUILD=release clean
mingw32-make.exe -f makefile.gcc MONOLITHIC=0 RC=1 SHARED=1 UNICODE=1 USE_OPENGL=1 BUILD=debug clean
mingw32-make -f makefile.gcc BUILD=release SHARED=1 MONOLITHIC=1 UNICODE=1 CXXFLAGS=-fno-keep-inline-dllexport >mingw32-make-release.txt 2>&1
mingw32-make -f makefile.gcc BUILD=debug SHARED=1 MONOLITHIC=1 UNICODE=1 CXXFLAGS=-fno-keep-inline-dllexport >mingw32-make-debug.txt 2>&1
This batch file worked to compile the both the release and debug versions.
I then started up the latest nightly build of Code::Blocks which is svn 1168 built on April 20, 2019. I navigated to "Settings => Compiler => Toolchain executables (tab)" . I did these settings:
Selected compiler: GNU GCC Compiler
Compiler's installation directory: C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64
C compiler: gcc.exe
C++ Compiler: g++.exe
Linker for dynamic libs: ld.exe
Linker for static libs: ld.exe
Debugger: GDB/CDB debugger: Default
Resource compiler: windres.exe
Make program: mingw32-make.exe
I then navigated to File => New project...
In the "New from template" dialog that opened I selected "wxWidgets" project, and clicked on "Go".
The wxWidgets version I selected was wxWidgets 3.1.x.
After entering the project name I did these radio button selections:
Preferred GUI Builder: wxSmith
Application type: Frame based
In the "wxWidgets location" field I entered: "C:\wxWidgets-3.1.2"
In the next compiler and configurations window I left all at default, but made sure both the Debug and the Release checkboxes were checked.
In "wxWidgets Library Settings" checked all checkboxes to match the options wxWidgets was compiled under. Checked were:
Use wxWidgets DLL ( Because SHARED=1 in the wxWidgets compilation command line )
wxWidgets is built as a monolithic library ( Because MONOLITHIC=1 in the wxWidgets compilation command line )
Enable Unicode ( Because UNICODE=1 in the wxWidgets compilation command line )
In "Miscellaneous Settings" I did these settings:
Create Empty Project: unchecked
Create and use Precompiled header (PCH): checked
Configure Advanced Options: checked
In "Advanced options (GCC only)"
Use_WXDEBUG_and Debut wxWidgets.lib: checked
In the "Debug Target" radio buttons:
GUI Mode Application: selected
In the "Release Target" radio buttons:
GUI Mode Application: selected
Upon clicking on "Finish" a starter project was created.
I navigated to "Project => Build options". In the project tree I selected "Debug" and set:
"Produce debugging symbols: [-g]": checked
I then selected "Debug" in the Code::Blocks menu bar and navigated to: "Project => Rebuild"
I got the error:
-------------- Clean: Debug in TIA Designer (compiler: GNU GCC Compiler)---------------
Cleaned "TIA Designer - Debug"
-------------- Build: Debug in TIA Designer (compiler: GNU GCC Compiler)---------------
g++.exe -Wall -pipe -mthreads -Winvalid-pch -include wx_pch.h -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -DWX_PRECOMP -g -D__WXDEBUG__ -IC:\wxWidgets-3.1.2\include -IC:\wxWidgets-3.1.2\lib\gcc_dll\mswud -c "C:\Engineering Software\TIA Designer\wx_pch.h" -o wx_pch.h.gch\Debug_wx_pch_h_gch
windres.exe -IC:\wxWidgets-3.1.2\include -IC:\wxWidgets-3.1.2\lib\gcc_dll\mswud -J rc -O coff -i C:\ENGINE~1\TI65BD~1\resource.rc -o obj\Debug\resource.res
g++.exe -Wall -pipe -mthreads -Winvalid-pch -include wx_pch.h -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -DWX_PRECOMP -g -D__WXDEBUG__ -IC:\wxWidgets-3.1.2\include -IC:\wxWidgets-3.1.2\lib\gcc_dll\mswud -c "C:\Engineering Software\TIA Designer\TIA_DesignerApp.cpp" -o obj\Debug\TIA_DesignerApp.o
g++.exe -Wall -pipe -mthreads -Winvalid-pch -include wx_pch.h -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -DWX_PRECOMP -g -D__WXDEBUG__ -IC:\wxWidgets-3.1.2\include -IC:\wxWidgets-3.1.2\lib\gcc_dll\mswud -c "C:\Engineering Software\TIA Designer\TIA_DesignerMain.cpp" -o obj\Debug\TIA_DesignerMain.o
ld.exe -LC:\wxWidgets-3.1.2\lib\gcc_dll -o "bin\Debug\TIA Designer.exe" obj\Debug\TIA_DesignerApp.o obj\Debug\TIA_DesignerMain.o obj\Debug\resource.res -mthreads -lwxmsw31ud -mwindows
ld.exe: unrecognised emulation mode: windows
Supported emulations: i386pep i386pe
Process terminated with status 1 (0 minute(s), 13 second(s))
0 error(s), 0 warning(s) (0 minute(s), 13 second(s))
This appears to be related to the -mwindows option for ld.exe. I looked for, and did not find, a means to remove this option, or select alternatives to it. Where did this go wrong? What needs to be done to make this work?
What is the value you set for the linker for dynamic libs?
Linker for static libs?
These are toolchain settings.
Linker for dynamic libs: ld.exe
Linker for static libs: ld.exe
The above are likely both wrong!
I will be trying
Linker for dynamic libs: x86_64-w64-mingw32-g++.exe
Linker for static libs: ar.exe
Tim S.
The Debugger tab:
Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: C:\Engineering Software\Test Posix\
Adding source dir: C:\Engineering Software\Test Posix\
Adding file: C:\Engineering Software\Test Posix\bin\Debug\Test Posix.exe
Changing directory to: C:/ENGINE~1/TESTPO~1/.
Set variable: PATH=.;C:\wxWidgets-3.1.2-posix\lib\gcc_dll;C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64;C:\Program Files (x86)\Pico Technology\SDK\lib;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Pololu\Simple Motor Controller\bin;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Bin;C:\Program Files\IVI Foundation\VISA\Win64\Bin;C:\Program Files\doxygen\bin;C:\Anaconda2;C:\Anaconda2\Scripts;C:\Anaconda2\Library\bin;C:\Program Files (x86)\Bitvise SSH Client;C:\Program Files (x86)\nodejs;C:\KicadBOM;C:\Program Files (x86)\Raisonance\Ride\bin;C:\Program Files (x86)\Pico Technology\PicoScope6;C:\Program Files (x86)\Pico Technology\Pico Full;C:\Program Files (x86)\Skype\Phone;C:\Program Files (x86)\IVI Foundation\IVI\Bin;C:\Program Files\IVI Foundation\IVI\Bin;C:\Program Files (x86)\National Instruments\Shared\LabVIEW CLI;C:\Program Files\TortoiseSVN\bin;C:\Users\spflanze\AppData\Local\Programs\Python\Python36-32\Scripts;C:\Users\spflanze\AppData\Local\Programs\Python\Python36-32;C:\Users\spflanze\AppData\Roaming\npm;C:\Program Files (x86)\CodeBlocks\MinGW\bin;C:\Program Files (x86)\Dr. Memory\bin
Starting debugger: C:\MinGW\bin\gdb.exe -nx -fullname -quiet -args C:/ENGINE~1/TESTPO~1/bin/Debug/TESTPO~1.EXE
done
Setting breakpoints
Debugger name and version: GNU gdb (GDB) 7.6.1
Starting the debuggee failed: No symbol table loaded. Use the "file" command.
Debugger finished with status 0
The Build log tab:
-------------- Clean: Debug in Test Posix (compiler: GNU GCC Compiler)---------------
Cleaned "Test Posix - Debug"
-------------- Build: Debug in Test Posix (compiler: GNU GCC Compiler)---------------
g++.exe -Wall -pipe -mthreads -Winvalid-pch -include wx_pch.h -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -DWX_PRECOMP -g -D__WXDEBUG__ -g -IC:\wxWidgets-3.1.2-posix\include -IC:\wxWidgets-3.1.2-posix\lib\gcc_dll\mswud -c "C:\Engineering Software\Test Posix\wx_pch.h" -o wx_pch.h.gch\Debug_wx_pch_h_gch
windres.exe -IC:\wxWidgets-3.1.2-posix\include -IC:\wxWidgets-3.1.2-posix\lib\gcc_dll\mswud -J rc -O coff -i C:\ENGINE~1\TESTPO~1\resource.rc -o obj\Debug\resource.res
g++.exe -Wall -pipe -mthreads -Winvalid-pch -include wx_pch.h -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -DWX_PRECOMP -g -D__WXDEBUG__ -g -IC:\wxWidgets-3.1.2-posix\include -IC:\wxWidgets-3.1.2-posix\lib\gcc_dll\mswud -c "C:\Engineering Software\Test Posix\Test_PosixApp.cpp" -o obj\Debug\Test_PosixApp.o
g++.exe -Wall -pipe -mthreads -Winvalid-pch -include wx_pch.h -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -DWX_PRECOMP -g -D__WXDEBUG__ -g -IC:\wxWidgets-3.1.2-posix\include -IC:\wxWidgets-3.1.2-posix\lib\gcc_dll\mswud -c "C:\Engineering Software\Test Posix\Test_PosixMain.cpp" -o obj\Debug\Test_PosixMain.o
x86_64-w64-mingw32-g++.exe -LC:\wxWidgets-3.1.2-posix\lib\gcc_dll -o "bin\Debug\Test Posix.exe" obj\Debug\Test_PosixApp.o obj\Debug\Test_PosixMain.o obj\Debug\resource.res -mthreads -lwxmsw31ud -mwindows
Output file is bin\Debug\Test Posix.exe with size 928.49 KB
Process terminated with status 0 (0 minute(s), 13 second(s))
0 error(s), 0 warning(s) (0 minute(s), 13 second(s))
I do not know what this "file" command is.
The -g option was in effect.
I removed the spaces in the paths. But the error message remained the same.
Build log:-------------- Clean: Debug in Test_Project_posix (compiler: GNU GCC Compiler)---------------
Cleaned "Test_Project_posix - Debug"
-------------- Build: Debug in Test_Project_posix (compiler: GNU GCC Compiler)---------------
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wall -g -g -IC:\wxWidgets-3.1.2-posix\include -IC:\wxWidgets-3.1.2-posix\lib\gcc_dll\mswu -c C:\Engineering_Software\Test_Project_posix\wx_pch.h -o wx_pch.h.gch\Debug_wx_pch_h_gch
windres.exe -IC:\wxWidgets-3.1.2-posix\include -IC:\wxWidgets-3.1.2-posix\lib\gcc_dll\mswu -J rc -O coff -i C:\ENGINE~1\TEST_P~2\resource.rc -o obj\Debug\resource.res
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wall -g -g -IC:\wxWidgets-3.1.2-posix\include -IC:\wxWidgets-3.1.2-posix\lib\gcc_dll\mswu -c C:\Engineering_Software\Test_Project_posix\Test_Project_posixApp.cpp -o obj\Debug\Test_Project_posixApp.o
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wall -g -g -IC:\wxWidgets-3.1.2-posix\include -IC:\wxWidgets-3.1.2-posix\lib\gcc_dll\mswu -c C:\Engineering_Software\Test_Project_posix\Test_Project_posixMain.cpp -o obj\Debug\Test_Project_posixMain.o
x86_64-w64-mingw32-g++.exe -LC:\wxWidgets-3.1.2-posix\lib\gcc_dll -o bin\Debug\Test_Project_posix.exe obj\Debug\Test_Project_posixApp.o obj\Debug\Test_Project_posixMain.o obj\Debug\resource.res -mthreads -lwxmsw31u -mwindows
Output file is bin\Debug\Test_Project_posix.exe with size 929.42 KB
Process terminated with status 0 (0 minute(s), 10 second(s))
0 error(s), 0 warning(s) (0 minute(s), 10 second(s))
Debug log:
Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: C:\Engineering_Software\Test_Project_posix\
Adding source dir: C:\Engineering_Software\Test_Project_posix\
Adding file: C:\Engineering_Software\Test_Project_posix\bin\Debug\Test_Project_posix.exe
Changing directory to: C:/Engineering_Software/Test_Project_posix/.
Set variable: PATH=.;C:\wxWidgets-3.1.2-posix\lib\gcc_dll;C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64;C:\Program Files (x86)\CodeBlocks\MinGW\bin;C:\Program Files (x86)\Dr. Memory\bin
Starting debugger: C:\MinGW\bin\gdb.exe -nx -fullname -quiet -args C:/Engineering_Software/Test_Project_posix/bin/Debug/Test_Project_posix.exe
done
Setting breakpoints
Debugger name and version: GNU gdb (GDB) 7.6.1
Starting the debuggee failed: No symbol table loaded. Use the "file" command.
Debugger finished with status 0
1) Settings->Debugger->Default->Executable path was:
C:\MinGW\bin\gdb.exe
This was not the same directory as the compiler. I made it the same.
2) The -g flag is in effect. This can be seen in the build log. It is actually in the compiler command line twice.
3) This is fixed now.
4) There is only one debugger in "Settings => Debugger", and it is the default one. The default debugger that is selected in "Settings => Compiler => Toolchain executables" is "GDB/CDB debugger : Default". This is the only choice there.
After the above fix (question 1) the error changed. When I attempt to step through the program I now get a error dialog opening with the message:
gdborig.exe has stopped working
A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available.
The checkbox at "Settings->Debugger->Common->Full (debug) Log" is now checked. The log in the Debugger tab:
Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: C:\Engineering_Software\Test_Project_posix_WXDEBG_\
Adding source dir: C:\Engineering_Software\Test_Project_posix_WXDEBG_\
Adding file: C:\Engineering_Software\Test_Project_posix_WXDEBG_\bin\Debug\Test_Project_posix_WXDEBG_.exe
Changing directory to: C:/Engineering_Software/Test_Project_posix_WXDEBG_/.
Set variable: PATH=.;C:\wxWidgets-3.1.2-posix\lib\gcc_dll;C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64;C:\Program Files (x86)\CodeBlocks\MinGW\bin;C:\Program Files (x86)\Dr. Memory\bin
[debug]Command-line: C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\gdb.exe -nx -fullname -quiet -args C:/Engineering_Software/Test_Project_posix_WXDEBG_/bin/Debug/Test_Project_posix_WXDEBG_.exe
[debug]Working dir : C:\Engineering_Software\Test_Project_posix_WXDEBG_
Starting debugger: C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\gdb.exe -nx -fullname -quiet -args C:/Engineering_Software/Test_Project_posix_WXDEBG_/bin/Debug/Test_Project_posix_WXDEBG_.exe
done
[debug]Reading symbols from C:/Engineering_Software/Test_Project_posix_WXDEBG_/bin/Debug/Test_Project_posix_WXDEBG_.exe...
[debug]done.
[debug](gdb)
[debug]> set prompt >>>>>>cb_gdb:
Setting breakpoints
[debug]>>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 8.1
[debug]Copyright (C) 2018 Free Software Foundation, Inc.
[debug]License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[debug]This is free software: you are free to change and redistribute it.
[debug]There is NO WARRANTY, to the extent permitted by law. Type "show copying"
[debug]and "show warranty" for details.
[debug]This GDB was configured as "x86_64-w64-mingw32".
[debug]Type "show configuration" for configuration details.
[debug]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]Find the GDB manual and other documentation resources online at:
[debug]<http://www.gnu.org/software/gdb/documentation/>.
[debug]For help, type "help".
[debug]Type "apropos word" to search for commands related to "word".
[debug]>>>>>>cb_gdb:
[debug]> set confirm off
Debugger name and version: GNU gdb (GDB) 8.1
[debug]>>>>>>cb_gdb:
[debug]> set width 0
[debug]>>>>>>cb_gdb:
[debug]> set height 0
[debug]>>>>>>cb_gdb:
[debug]> set breakpoint pending on
[debug]>>>>>>cb_gdb:
[debug]> set print asm-demangle on
[debug]>>>>>>cb_gdb:
[debug]> set unwindonsignal on
[debug]>>>>>>cb_gdb:
[debug]> set print elements 200
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor att
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> directory C:/Engineering_Software/Test_Project_posix_WXDEBG_/
[debug]Source directories searched: C:/Engineering_Software/Test_Project_posix_WXDEBG_;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> start
[debug]Temporary breakpoint 2 at 0x4068d9
[debug]Starting program: C:\Engineering_Software\Test_Project_posix_WXDEBG_\bin\Debug\Test_Project_posix_WXDEBG_.exe
Child process PID: 10296
[debug][New Thread 10296.0x2bd0]
[debug]Temporary breakpoint 2, 0x00000000004068d9 in main ()
[debug]>>>>>>cb_gdb:
[debug]> info frame
Debugger finished with status 1
In "Settings => Compiler => Toolchain executables" I made these changes:
C Compiler:
From: gcc.exe
To: x86_64-w64-mingw32-gcc.exe
C++ Compiler:
From: g++
To: x86_64-w64-mingw32-g++.exe
After the above changes I got the same result. The Same error dialog opened with message that "gdborig.exe has stopped working".
Your help on this is much appreciated. :)