1

I was trying use build wxWidgets-3.1.3 with MinGW-W64 on a x64 windows machine.

I followed this thread, which lead me to download and building. So I installed it and some youtube videos said I need to build it now. So navigate to the installed folder and gave this command :

mingw32-make -f makefile.gcc BUILD=release SHARED=1 MONOLITHIC=1 UNICODE=1.

It took almost half an hour and now it's giving me error saying :

collect2.exe: error: ld returned 1 exit status
makefile.gcc:5329: recipe for target '..\..\lib\gcc_dll\wxmsw313u_gcc_custom.dll' failed
mingw32-make: *** [..\..\lib\gcc_dll\wxmsw313u_gcc_custom.dll] Error 1

Here is the full log file :

https://pastebin.com/zxeHhF6K

MinGW configuration :

Version : 8.1.0
Architecture : x86_64
Threads : posix
Exceptions : seh
Build version : 0

How can I solve this? I'm using CLion, is there any other short or easy way?

Maifee Ul Asad
  • 3,992
  • 6
  • 38
  • 86
  • could you please try with just `mingw32-make -f makefile.gcc BUILD=release`? Also which version of MinGW do you use? – Igor Nov 01 '19 at 12:46
  • version is 8.1.0, btw I have added full config in the que – Maifee Ul Asad Nov 01 '19 at 12:56
  • did you try to rebuild with the command I suggested? – Igor Nov 01 '19 at 14:16
  • That command exited without error, a few minute ago. but I can't still configure it in CLion, so is it done ? – Maifee Ul Asad Nov 01 '19 at 14:49
  • 1
    if it finishes without errors than everything is good. You can check it by doing this: `cd samples\minimal && mingw32-make -f makefile.gcc BUILD=release && minimal`. Configuring CLion is completely different topic. You need to explain what you are doing there and how do you configure it. – Igor Nov 01 '19 at 15:01
  • BTW, why did you decide to build a release version of the library? You SHOULD start with `mingw32-make -f makefile.gcc BUILD=debug`. – Igor Nov 01 '19 at 15:02
  • [here](https://gist.github.com/maifeeulasad/28ff22f647d1a08b85823f3d892e7e97) is my CLion's makefile ... i followed [this](https://youtu.be/FgAaiBg4wEE?t=266) tutorial... i just searched how to use wxWidgets in CLion and it came.. – Maifee Ul Asad Nov 01 '19 at 15:15
  • you should configure the project in CLion the usual way - by adding the include and library path and the appropriate libraries to link with. – Igor Nov 01 '19 at 16:06

2 Answers2

0

The relevant error is

..\..\lib\gcc_dll/libwxexpat.a(wxexpat_xmlparse.o):xmlparse.c:(.text+0x337d): undefined reference to `_imp__rand_s'

and it's very strange because MinGW-w64 8.1 is definitely supposed to have rand_s(). Are you sure you're using the right compiler? I.e. what does g++ -v give you if you run it from the same command prompt?

My only hypothesis is that it's some different (and much older) compiler and the solution would be to just use the right one instead.

Also, the next time you could use -j4 option with make if you have at least 4 logical CPUs in your machine (and chances are you do nowadays), to significantly speed up the build.

VZ.
  • 21,740
  • 3
  • 39
  • 42
0

Looking back in my notes I once had an issue with missing rand_s() when building glib2 on a certain MinGW build.

I was able to fix it then by adding this at the top of the C file that called this function:

#include <time.h>
#include <stdlib.h>
int rand_s (unsigned int* r)
{
  static int srand_called = 0;
  if (!srand_called) {
    srand(time(0));
    srand_called++;
  }
  if (r)
    *r = rand();
  return 0;
}

In your case that would be in xmlparse.c.

Brecht Sanders
  • 6,215
  • 1
  • 16
  • 40