mingw + gcc + gnu + -ggdb -g3 but debugging failed "no source info" - c++

Under Windows with same i686-w64-mingw32-gcc I have two C++ projects. Both with "-ggdb -g3 -O0" - the smaller project I can debug in Eclipse but the larger one says "No source available". Both projects with " -static-libgcc -static-libstdc++"
I am failing to figure out what breaks it :(
Smaller project happy gdb:
Larger prodject not happy gdb:
Good makefile:
https://github.com/rusefi/rusefi/blob/temp_branch/unit_tests/Makefile
https://github.com/rusefi/rusefi/blob/temp_branch/unit_tests/rules.mk
Bad makefile:
https://github.com/rusefi/rusefi/blob/temp_branch/win32_functional_tests/Makefile
https://github.com/rusefi/rusefi/blob/temp_branch/win32_functional_tests/rules.mk
Both projects show symbols with objdump.exe --syms:
Good project symbols:
https://github.com/rusefi/rusefi/blob/temp_branch/unit_tests/symbols
Bad project symbols:
https://github.com/rusefi/rusefi/blob/temp_branch/win32_functional_tests/symbols
I would like to be able to debug both projects. What am I doing wrong? :(

Update: I've found a work-around:
i686-w64-mingw32-gcc (32bit embedded into Cygwin64) does not work with gdb from cygwin64
but if everything is base 32 bit cygwin things work as expected! Just to reiterate - one project works with 32 compiler from cygwin64 while another one does not, so something must be different - but since I have a workaround I am good.

Related

Cray compiler asks for a flag, then doesn't recognize it

I am trying to compile a code with crayftn.
I get an error message
/opt/cray/pe/cce/10.0.1/binutils/x86_64/x86_64-pc-linux-gnu/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
So it wants the flag --no-relax? OK, I can do that. So I re-link with that flag, and then it tells me
ftn -O3 --no-relax -dynamic -h pic -h omp -o stream_cray stream_mpi.o mysecond.o
ftn-2115 crayftn: ERROR in command line
"-no-relax" is an invalid command-line option.
So it asks for "--no-relax", but then it doesn't understand it. Anyone know of a way out of this conundrum? Or another way of solving the root problem in the first place?
I found this link:
https://bb.cgd.ucar.edu/cesm/threads/failed-to-convert-gotpcrel-relocation-relink-with-no-relax.4494/
PROBLEM:
Hi, I get the following error message for CLM5.0 compilation with
Intel compilers, during the final cesm bld ..ld: failed to convert GOTPCREL relocation; relink with --no-relax
SOLUTION:
Hi, Seems like found a solution to fix the compilation ...Adding of
"-Wl,--no-relax" in LDFLAGS does not solve this problem, but
"-mcmodel medium" in FFLAGS fixes this issue, after searching for
"Relocation truncated to fit" in google search engine, it comes up
with this link which was helpful to solve the issue
"https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/268394"
Best Regards,Prabhakar
See also:
https://community.intel.com/t5/Intel-Fortran-Compiler/relocation-truncated-to-fit/td-p/1146616
This looks like mixing compilers and libraries from different systems
mixed up, either 32bit vs. 64bit or installations for ifort and
mpiifort based on different glibc or something similar.
I'm still curious about your "development environment":
Q: Have you been able to successfully compile, link and run ANY
program with your crayftn? Q: What version of crayftn? 10.0.1? Q: What
platform? Where is x86_64-pc-linux coming from? Just curious...

inability to compile fortran 90 codes

I am using a bash shell on my Mac OS X. I have fortran95 compiler installed in /sw/bin/gfortran. every time I attempt to access the compiler, I receive
the error:
"Segmentation fault: 11". I cannot call any programs the regular way
i.e. "gfortran program.f90 -o executable_name "
I am not sure about the problem. Even simple programs which print "hello world" to screen will not work.
May be a problem with your installation as already mentioned. A couple things I would try:
Make sure the shared libraries it is compiled against are being found:
otool -L /sw/bin/gfortran
Compile with some switches that might give you more helpful info. I found using the backtrace option really helps especially to debug seg. faults. You might try to compile with some options such as:
gfortran -g -fbounds-check -Wall -fbacktrace program.f90

Compiling DISLIN gfortran

I am having trouble compiling Fortran code with references to DISLIN. I have downloaded DISLIN from the website, unzipped the file and ran the setup. I have added an environment variable called DISLIN (C:\dislin) and added C:\dislin\win to the PATH section of my system variables.
I am trying to compile some example code of the DISLIN website which includes line
USE DISLIN
I am using a MinGW shell to compile with command gfortran -o progrname -ldislin EX11_1.f90 and am getting the following error:
Fatal Error: Cant open module file 'dislin.mod' for reading at (1): No such file or directory.
I have tried changing the variable path and even moving the dislin.mod file (which is there) but still get the same message.
Ok I fixed this problem so thought I come back and post what worked for me incase any one else needs it...
Install both DISLIN and MinGW on the c drive
Copy disgf.a from /c/dislin and dislin.f90 from /c/dislin/gf into the directory containing your fortran files
(for me this is /c/MinGW/pnote)
Using the MinGW shell navigate to you files: cd /c/MinGW/pnote
compile dislin.f90 and your fortran program: gfortran -c dislin.f90 progName.f90 (dislin.f90 obviously only needs to be done once)
link libraries etc and compile: gfortran progName.o disgf.a -luser32 -lgdi32 -lopengl32 -o exeName
'run' exeName
You probably need to specify the path to the DISLIN module files:
gfortran EX11_1.f90 -o progrname -ldislin -I/path/to/DISLIN/modules
and, if not already configured like described here, also the path to the library itself:
gfortran EX11_1.f90 -o progrname -ldislin -I/path/to/DISLIN/modules \
-L/path/to/DISLIN/library
They provide a batch file (windows) to do the compiling and linking for you.
f90link -c My_Program
This is located in c:\dislin\Win
Also, if you are having trouble with the dislin.mod file which resides in c:\dislin\gf then recompile that with the -c compile option. I found all of this info in c:\dislin\readme.inf
near as I can tell (Jan 2018) dislin (64 bit) fails miserably with gfortran 7.2, period; and probably with many other newer compilers.
When trying to link, gfortran 7 says 'dislin.mod' is an unrecognizable format.
I think this program is highly dependent on exactly correct version synchronization - something that renders such software useless imho after many years in research.
and no, the correctness of various 'paths' seems not to help.
after all, gnuplot works, "at all". Not sure why I spent so much time on brand x.
jrc

How to compile a C++ program as 64-bit on 64-bit machine?

Perhaps a very trivial question:
I need to compile a program as 64-bit (earlier makefile written to compile it as 32-bit).
I saw the option -m32 appearing in command line parameters with each file compilation. So, I modified the makefile to get rid of -m32 in OPTFLAG, but again when the program compiles, I still see -m32 showing up and binaries are still 32-bit. Does this m32 come from somewhere else as well?
-m32 can only be coming from somewhere in your makefiles, you'll have to track it down (use a recursive grep) and remove it.
When I am able to force -m64, I get "CPU you selected does not support x86-64 instruction set".Any clues?. uname -a gives x86_64
That error means there is an option like -march=i686 in the makefiles, which is not valid for 64-bit compilation, try removing that too.
If you can't remove it (try harder!) then adding -march=x86-64 after it on the command line will specify a generic 64-bit CPU type.
If the software you are trying to build is autotools-based, this should do the trick:
./configure "CFLAGS=-m64" "CXXFLAGS=-m64" "LDFLAGS=-m64" && make
Or, for just a plain Makefile:
env CFLAGS=-m64 CXXFLAGS=-m64 LDFLAGS=-m64 make
If you are using CMake, you can add m64 compile options by this:
add_compile_options(-m64)

Displaying info in the eclipse console

I'm trying to compile a C++ project (Hello World) in windows 7 using Eclipse Helios. After creating the project the console shows me the next message:
Internal Builder is used for build **
g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\hello.o ..\src\hello.cpp
g++ -ohello.exe src\hello.o
c:/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../../mingw32/bin/ld.exe:
warning: auto-importing has been activated without --enable-auto-import specified on the command line.
If I open the command line and execute: g++ hello.cpp -Wl,-enable-auto-import, I can generate the exe file and I can run it.
In eclipse after adding the argument "-Wl,--enable-auto-import" in the MinGW C++ Linker - Miscellaneous section, I didn't get any warning however, the console is always empty. Again, using the command line, if I move to the directory and execute the exe file generated by eclipse I get the expected result.
I know that Eclipse is compiling the cpp file properly but, why the eclipse console is not displaying the info? Is something missing in the configuration?
Sorry guys my stupid question.
I appreciate your help.
This looks like an environment variable(s) and/or register paths problem.