wjp / idados

Eric Fry's IDA/DOSBox debugger plugin
131 stars 26 forks source link

Trouble building DOSBox for IDA 6.8 with fresh MSys2 installation #7

Open RayKoopa opened 8 years ago

RayKoopa commented 8 years ago

I have several issues being able to build IdaDOS and DOSBox on a fresh MSys2 installation when strictly following BUILD.md as I'm new to MSys2. There are some things which can be tricky for a beginner like me, which I bolded. I still can't compile DOSBox correctly eventually.

Sorry that I can't even teach Github to continue my list numbers when using code blocks.

Preparations

  1. Install MSys2 from http://msys2.github.io/ (msys2-i686-20160205.exe) and running it.
  2. Running pacman -S mingw-w64-i686-toolchain (installing all members)
  3. Running pacman -S mingw-w64-i686-SDL as I need to build DOSBox too later on.
  4. Copying my idasdk68 to /d/idasdk68.

Compiling IdaDOS

  1. Download idados into /d/idados.
  2. Since I use IDA 6.8, change two lines back to what was changed here: https://github.com/wjp/idados/commit/8b0ef6a650e8b45bd3ed8ae9c179ef0bb857bd53
  3. Editing build_mingw.sh to use ../idasdk68 rather than ../idasdk69
  4. Starting MSys2 with the "MinGW-w64 Win32 Shell" shortcut in the MSys2 folder in the start menu.
  5. Switching to /d/idados and executing ./build_mingw.sh.
  6. Getting the following error:
In file included from ../idasdk68/plugins/debugger/tcpip.h:4:0,
from dosbox_rstub.cpp:15:
../idasdk68/include/pro.h:735:84: error: conflicting declaration of C function 'int memicmp(const void*, const void*, size_t)'
idaman THREAD_SAFE int ida_export memicmp(const void *x, const void *y, size_t size);
  1. Thinking this is the issue actually described under the "DOSBox" compilation section in BUILD.md. Thus, changing #ifdef __GNUC__ in pro.h to #if 0 so it looks like this:
#if 0
idaman THREAD_SAFE int ida_export memicmp(const void *x, const void *y, size_t size);
#endif
  1. Executing ./build_mingw.sh again. Getting the error:
C:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lida
collect2.exe: error: ld returned 1 exit status
  1. Also copying over ida.wll into /d/idasdk68/bin/ida.dll as actually described under the "DOSBox" section in BUILD.md.
  2. Now, compiling the IdaDOS plugin works flawlessy.
  3. Copying dosbox_rstub.plw to my IDA plugin directory.
  4. Copying C:\msys32\mingw32\bin\libwinpthread-1.dll to my IDA installation directory.

The notes about __GNUC__ and ida.dll should probably go under the IdaDOS section already.

Compiling DOSBox

  1. Download DOSBox repository from https://github.com/wjp/dosbox into /d/dosbox.
  2. Switching into that directory with MSys2.
  3. Running .autogen-sh. Getting the following output:
Generating build information using aclocal, autoheader, automake and autoconf
This may take a while ...
./autogen.sh: line 8: aclocal: command not found
./autogen.sh: line 9: autoheader: command not found
./autogen.sh: line 10: automake: command not found
./autogen.sh: line 11: autoconf: command not found
Now you are ready to run ./configure.
You can also run  ./configure --help for extra features to enable/disable.
  1. Trying to install the missing commands with pacman -Su automake and pacman -Su autoconf.
  2. Re-running ./autogen-sh. Getting quite a few warnings about source files being in subdirectories (if required, I can upload the warnings). But no errors.
  3. Running ./configure --enable-debug=ida32 --with-ida-sdk=/d/idasdk68 --with-ida-plugin=/d/idados, no errors.
  4. Running make. Noticing it's not installed. Installing it with pacman -Su make.
  5. Getting the following error:
In file included from debug.cpp:47:0:
debug_inc.h:22:20: fatal error: curses.h: No such file or directory
compilation terminated.
  1. Looking up how to get curses.h, following the instructions found in http://www.dosbox.com/wiki/BuildingDOSBox under the "Enabling the debugger (You probably don't want this)" section (requiring to install tar too).
  2. Switching back to the DOSBox directory and re-running make, now running without errors (build log on request).
  3. Copying src/DOSBox.exe into my DOSBox 0.74 directory.
  4. Trying to start it, missing some DLLs, requiring me to copy over libgcc_s_dw2-1.dll and libwinpthread-1.dll from C:\msys32\mingw32\bin as it is not in my PATH. Also having to copy over IDA.WLL from my IDA directory.
  5. Starting DOSBox again. Getting following error:
The procedure entry point _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13find_first_ofEPKcjj could not be located in the dynamic link library D:\Archive\Games\Emulators\DOSBox Debug\DOSBox.exe. 

I'm out of ideas, I had a similar error yesterday about a missing symbol. What do I have to do to correctly compile DOSBox?

wjp commented 8 years ago

Thanks for the detailed write-up. I'll look at it in detail later, but to start with the error at the end: that looks like a symbol from libstdc++. Do you have a libstdc++.dll (or maybe similar) in C:\msys32\mingw32\bin that you could also try copying to the dosbox directory?

RayKoopa commented 8 years ago

In fact, I had libstdc++-6.dll, copying that into the DOSBox directory helped. Funny, I thought if Windows says it doesn't find the symbol in DOSBox.exe, it had to be compiled into it =3

Artoymyp commented 6 years ago

I had some specific problems with my MinGW/MSys installation. Make command resulted in some compiller errors like: ::sprintf has not been declared in some *.cpp.

I have solved it by adding at the top of all problem cpp-files the following include: #include <cstdio>

On a side note. RayKoopa, just let me to kiss you for three times! I have meddled in all this mess for three evenings straight, just until I have found your marvelous instruction for MinGW begginners.