Question

After compiling codes in Ubuntu 12.04.3 for a while, I decided to give coding in Windows a go and installed MinGW. After the installation I set my path variables and the gcc seemed to work. However, some codes(especially those including multiple files) cannot be compiled with the same command used on Ubuntu and various error messages are displayed in the MinGW shell. Is this the expected behavior or am I doing something wrong? I appreciate your assistance.

P.S: Displayed error message

 QROMO.C: In function 'float qromo(float (*)(float), float, float, float (*)(float (*)(float), float, float, int))':
QROMO.C:24:43: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
  nrerror("Too many steps in routing qromo");
                                           ^
C:\Users\dell\AppData\Local\Temp\ccUdzH1p.o:Q2.c:(.text+0xd5): undefined reference to `midexp'
C:\Users\dell\AppData\Local\Temp\ccUdzH1p.o:Q2.c:(.text+0xf3): undefined reference to `qromo'
C:\Users\dell\AppData\Local\Temp\ccUdzH1p.o:Q2.c:(.text+0x115): undefined reference to `qgaus'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: C:\Users\dell\AppData\Local\Temp\ccUdzH1p.o: bad reloc address 0x20 in section `.eh_frame'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status

Edit: The errors seem to be related with QROMO.c and POLINT.c during compilation stage. The received error messages are as follows:

POLINT.C: In function 'void polint(float*, float*, int, float, float*, float*)':
POLINT.C:28:62: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
    if ( (den=ho-hp) == 0.0) nrerror("Error in routine polint");
                                                              ^


QROMO.C: In function 'float qromo(float (*)(float), float, float, float (*)(float (*)(float), float, float, int))':
QROMO.C:24:43: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
  nrerror("Too many steps in routing qromo");
                                           ^
Was it helpful?

Solution

Since you're getting the error:

warning: deprecated conversion from string constant to 'char*'

I guess you're compiling using C++ compiler as the C++11 deprecating conversion from string constant to 'char*'.

§ C.1.1
char* p = "abc"; // valid in C, invalid in C++

You cannot get this error if you're compiling with a C compiler as this conversion still valid in C.

Compiling with a C++ compiler can generate many errors if your program is not C++ compatible.

So just make sure to compile using a C compiler.

OTHER TIPS

The important part is the errors at the bottom:

Q2.c(...): undefined reference to `midexp'
Q2.c(...): undefined reference to `qromo'
Q2.c(...): undefined reference to `qgaus'
...
...ld.exe: final link failed: Invalid operation
...

This means you have undefined references, and is nothing specific to MinGW or Windows 7.

I'm assuming though, that these are defined in their respective source files which are included in a seemingly correct order on your compile/link line. I would suggest splitting the compile and link steps, and see where it goes wrong. This will turn the now temporar object files with randomly generated names into object files you know because you created them. You can use nm to inspect object files and see if everything is as it should be.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top