How to fix linking errors with gfortran compiler? - eclipse

I downloaded Eclipse and Cygwin for windows 7 64 bit. I wrote the next Fortran program:
program main
print*, 'Hello World'
end program main
and got the next error when I tried to build the program:
make all
Building target: examples
Invoking: GNU Fortran Linker
gfortran -o "examples" ./main.o
gfortran: fatal error: -fuse-linker-plugin, but cyglto_plugin.dll not found
compilation terminated.
makefile:29: recipe for target 'examples' failed
make: *** [examples] Error 1
I looked for the file cyglto_plugin.dll, and found it in the folder:
C:\cygwin64\lib\gcc\x86_64-pc-cygwin\4.9.3
I tried to add this folder to the PATH environment variable but still got the same error.
Searching the web I found out that the problem can be solved by installing as a dependency the library cyglto_plugin.dll, which is used for Link-Time-Optimization, and can be found in the package gcc-core. However, I have no idea how to do it, can someone instruct me please ?
Using the command prompt I disabled this library by typing:
$ gfortran main.f90 -fno-use-linker-plugin -o main
doing so I got a bunch of new errors:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find crtbegin.o: No such file or directory
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lquadmath
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/../../../../x86_64-pc-cygwin/bin/ld: cannot find crtend.o: No such file or directory
Do someone has an idea how to fix these errors ?

Related

gcc49 on Fedora 27: /usr/bin/ld: cannot find -lgcc_s

I am using the davidva/gcc49 copr, on Fedora 27.
When I try to compile after running source /usr/bin/gcc49 as the copr webpage describes, I get this error:
/usr/bin/ld: cannot find -lgcc_s
After learning about how the flag -l works for gcc, I learned it is looking for library gcc_s. I found it in /opt/gcc-4.9.3/lib64/gcc/x86_64-fedoraunited-linux-gnu/lib64, which sounds like the right spot for it to be. Why is it not linking? Do I need to add a directory to a library path? If it's LDFLAGS, it's already there because of the file I sourced:
export LDFLAGS="-L/opt/gcc-$gver/$lib/gcc/$gcc_target_platform/$lib/"
What do I need to do to get gcc 4.9 on Fedora 27 to find its library file which is clearly in the LDFLAGS directory?
The problem is that the libgcc_s.so file is in the wrong directory! Just symlink to it in the 4.9.3 directory:
pushd /opt/gcc-4.9.3/lib64/gcc/x86_64-fedoraunited-linux-gnu/4.9.3
sudo cp -p ../lib64/libgcc_s.so.1 .
sudo ln -s libgcc_s.so.1 libgcc_s.so
popd
I guess the /opt/gcc-4.9.3/lib64/gcc/x86_64-fedoraunited-linux-gnu/lib64 directory was supposed to be included in any LDFLAGS parameter, and that might be a weakness of the build process I was using and not the gcc 4.9 package.
Putting this file and appropriately-named symlink in the 4.9.3 directory allows my build process to complete successfully.
Reference: https://bgstack15.wordpress.com/2018/02/01/gcc-4-9-for-fedora-27/

unable to complie and install perl module: Audio::Scan

i am using "perl 5, version 18, subversion 2 (v5.18.2) built for MSWin32-x86-multi-thread-64int" on windows 7 enterprise(SP1).
I am trying to compile and install a perl module Audio::Scan (.71 version). I downloaded the module from cpan.org, extracted it locally in my machine. It contains readme.win32 text file which states the following:
zlib
The included zlib.lib should just work, if not: Download zlib from http://www.zlib.net/zlib123.zip.
Build from projects/visualc6/zlib.dsw.
Build Win32_LIB_Release Copy zlib.lib into the Audio::Scan win32 directory.
Audio::Scan
Install ActivePerl 5.8.8 or 5.10.0. Open command prompt. Run the vcvars file, for example C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat
perl Makefile.PL
nmake
nmake test
END
I followed all the steps till nmake. The step before nmake i executed like this "perl Makefile.PL make=nmake" as it was generating it dmake style by default. This step goes well.
But in nmake step, i get a lot of warnings followed by the following error:
win32/zlib.lib(./Win32_LIB_Release/crc32.obj):(.text$mn+0x22): undefined reference to #__security_check_cookie#4'
win32/zlib.lib(./Win32_LIB_Release/crc32.obj):(.text$mn+0x1be): undefined reference to#__security_check_cookie#4'
c:/perl/site/lib/auto/mingw/bin/../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/bin/ld.exe: win32/zlib.lib(./Win32_LIB_Release/crc32.obj): bad reloc address 0x1be in section `.text$mn'
c:/perl/site/lib/auto/mingw/bin/../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/bin/ld.exe: final link failed: Invalid operation
collect2: ld returned 1 exit status NMAKE : fatal error U1077: 'C:\Perl\site\bin\g++.EXE' : return code '0x1'
Stop.
I read this thread http://www.perlmonks.org/?node_id=496624 checked the compiler used to compile perl as follows:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC>perl -V:cc..
it returned
cc='gcc';
I am stuck at this point. Any help would be highly appreciated. Sorry for typos if any.

CMake fails to generate Makefiles with Sun Studio 12.5

I'm working on Solaris 11.3 with Sun Studio 12.5. When I attempt to configure with Cmake out-of-tree, Cmake finishes with configuration errors and does not produce the makefiles. In-tree may be broken, too. But our procedures say to build out-of-tree, so that;' what I do.
I have nearly no Cmake experience. Others contributed the the CMake files, and I struggle with tasks related to them. I'm not sure if I am doing something wrong, if our Cmake files are broken, or if Cmake is not well tested under Solaris.
What is going on with CMake, and how do I fix it?
Here are the links to the Cmake files. I can copy/paste them, but it just takes up a bunch of space. The files are hosted on GitHub so they should always be available.
CMakefileList.txt
cryptopp-config.cmake
Here is Solaris' Cmake version, prior to me installing 3.6.2:
$ cmake --version
cmake version 2.8.6
Below is from Solaris Cmake version 2.8.6.
cryptopp-build$ export CXX=/opt/developerstudio12.5/bin/CC
cryptopp-build$ export CXXFLAGS="-DNDEBUG -g2 -O2 -D__SSE2__ -D__SSE3__ -D__SSSE3__ -D__SSE4_1__ -D__SSE4_2__ -D__AES__ -D__PCLMUL__ -D__RDRND__ -D__RDSEED__ -D__AVX__ -D__AVX2__ -D__BMI__ -D__BMI2__ -D__ADX__ -xarch=avx2_i"
cryptopp-build$ cmake ../cryptopp
-- The CXX compiler identification is unknown
-- Check for working CXX compiler: /bin/c++
-- Check for working CXX compiler: /bin/c++ -- broken
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestCXXCompiler.cmake:45 (MESSAGE):
The C++ compiler "/bin/c++" is not able to compile a simple test program.
It fails with the following output:
Change Dir: /export/home/test/cryptopp-build/CMakeFiles/CMakeTmp
Run Build Command:/bin/gmake "cmTryCompileExec/fast"
/bin/gmake -f CMakeFiles/cmTryCompileExec.dir/build.make
CMakeFiles/cmTryCompileExec.dir/build
gmake[1]: Entering directory
`/export/home/test/cryptopp-build/CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report
/export/home/test/cryptopp-build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building CXX object CMakeFiles/cmTryCompileExec.dir/testCXXCompiler.cxx.o
/bin/c++ -DNDEBUG -g2 -O2 -D__SSE2__ -D__SSE3__ -D__SSSE3__ -D__SSE4_1__
-D__SSE4_2__ -D__AES__ -D__PCLMUL__ -D__RDRND__ -D__RDSEED__ -D__AVX__
-D__AVX2__ -D__BMI__ -D__BMI2__ -D__ADX__ -xarch=avx2_i -o
CMakeFiles/cmTryCompileExec.dir/testCXXCompiler.cxx.o -c
/export/home/test/cryptopp-build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
c++: error: language arch=avx2_i not recognized
c++: error: language arch=avx2_i not recognized
gmake[1]: Leaving directory
`/export/home/test/cryptopp-build/CMakeFiles/CMakeTmp'
gmake[1]: *** [CMakeFiles/cmTryCompileExec.dir/testCXXCompiler.cxx.o] Error
1
gmake: *** [cmTryCompileExec/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:9 (project)
-- Configuring incomplete, errors occurred!
And:
$ /opt/developerstudio12.5/bin/CC -V
CC: Studio 12.5 Sun C++ 5.14 SunOS_i386 2016/05/31
I built Cmake 3.6.2 from sources and installed in /usr/local to attack the CXX compiler identification is unknown issue, but it appears to be having some troubles. As I said earlier, I'm not a Cmake expert (and I'm not sure how one can mess up a make && sudo make install).
cryptopp-build$ cmake ../cryptopp
CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in
/usr/local/bin
CMake Error: Error executing cmake::LoadCache(). Aborting.
Clearing the cache as suggested by #AndrewHenle results in:
# The project GNUmakefile clears all Cmake artifacts because Cmake cannot seem to do it on its own
$ cd cryptopp
$ git status -s
$
$ cd ..
$ rm -rf cryptopp-build
$ mkdir cryptopp-build
$ cd cryptopp-build
# Using 3.6.2 now
$ cmake ../cryptopp
CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in
/usr/local/bin
CMake Error: Error executing cmake::LoadCache(). Aborting.
So there appeared to be two problems. First was the down level Sun supplied Cmake. There's nothing genius about diagnosing it as "too old".
The second issue was more interesting. It appears the CMake Error: Could not find CMAKE_ROOT !!! was cause by sudo make install Once I switched to sudo gmake install the issue went away.
Here are the bug reports on the issue:
Cmake Issue 16302: Cmake fails to identify Sun Studio 12.5 compiler
Cmake Issue 16303: Cmake fails to produce a working installation on Solaris 11.3

Unable to compile "hello world" program with Swift on Ubuntu 14.04

Using Ubuntu 14.04
Distributor ID: Ubuntu
Description: Ubuntu 14.04.3 LTS
Release: 14.04
Codename: trusty
and trying to compile a hello world Swift program.
print("Hello World!")
I have verified the download:
gpg --verify swift-2.2-SNAPSHOT-2015-12-10-a-ubuntu14.04.tar.gz.sig
gpg: Signature made Thu 10 Dec 2015 07:17:37 PM PST using RSA key ID 412B37AD
gpg: Good signature from "Swift Automatic Signing Key #1 <swift-infrastructure#swift.org>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: 7463 A81A 4B2E EA1B 551F FBCF D441 C977 412B 37AD
But when I try and compile the hello world program I get this error:
> swiftc hello_world.swift
<unknown>:0: error: opening import file for module 'SwiftShims': No such file or directory
If I start up the Swift REPL I get a similar error:
~$ swift
Welcome to Swift version 2.2-dev (LLVM 7bae82deaa, Clang 53d04af5ce, Swift 5995ef2acd). Type :help for assistance.
1> y = 6
opening import file for module 'SwiftShims': No such file or directory
1>
If I follow the instructions given here on using "swift build" versus "swiftc" for compiling a Hello World Swift program, I get a different error:
$ swift build
<unknown>:0: error: opening import file for module 'Swift': No such file or directory
swift-build: exit(1): ["/home/scooter/Programs/Swift/V2.2/bin/swiftc", "--driver-mode=swift", "-I", "/home/scooter/Programs/Swift/V2.2/lib/swift/pm", "-L", "/home/scooter/Programs/Swift/V2.2/lib/swift/pm", "-lPackageDescription", "/home/scooter/code/swift/helloworld-project/Package.swift"]
Executing the interpreter:
$ swift hello_world.swift
gives
<unknown>:0: error: opening import file for module 'SwiftShims': No such file or directory
strace gets an error trying to run swift:
$ strace -o /tmp/swift.log -- swift <(echo '1 + 1')
<unknown>:0: error: opening import file for module 'SwiftShims': No such file or directory
open("/home/user/Programs/Swift/V2.2/lib/swift/linux/x86_64/SwiftShims.swiftmodule",
O_RDONLY) = -1 ENOENT (No such file or directory)
Sorry for adding as an answer what should have really been a comment content-wise, but it is a little too long for a comment.
As far as I can tell, this is indeed the same problem as described in Swift on Linux: Make very first step work. I have been looking into this myself in my spare time, but no luck so far. The user who asked the other question has been pursuing it and has some interesting recent updates there.
A few things to try:
See if the swift interpreter works. Just type swift hello_world.swift and see what happens. I don't think it will work. If it does not, then run the strace command as follows:
strace -o /tmp/swift.log -- swift <(echo '1 + 1')
and look at /tmp/swift.log. See what files cannot be found, especially near the end of the output. Warning: even on a system where the error doesn't happen (I haven't been able to reproduce it yet), the strace output shows a lot of No such file... errors.
You can also try swift and swiftrc with the -v option to enable verbose output and see if you notice anything suspicious.
Update 1/2/2016:
The question referenced earlier has been updated with a possible solution to the problem: get rid of non-standard installations of gcc, g++, libgcc, and libstdc++. Please see the comments in the other question.
Update 1/3/2016:
Using the clues from the discussion on the other question, I've been able to reproduce the problem by installing gcc-5.1.0 from source and pre-pending the location of the newly-installed libstdc++.so.6 to the LD_LIBRARY_PATH variable.
The problem could be solved as follows:
1) Figure out where libstdc++.so.6 from the older package is installed. On my system:
user#ubuntu14:~$ dpkg -l | grep libstdc++
ii libstdc++-4.8-dev:amd64 4.8.4-2ubuntu1~14.04 amd64 GNU Standard C++ Library v3 (development files)
ii libstdc++6:amd64 4.8.4-2ubuntu1~14.04 amd64 GNU Standard C++ Library v3
user#ubuntu14:~$ dpkg -L libstdc++6 | grep libstdc++.so
/usr/share/gdb/auto-load/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19-gdb.py
/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
2) Prepend the location of libstdc++.so.6 to $LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
3) Double-check that the swift binary is using the correct shared library:
user#ubuntu14:~$ ldd `which swift` | grep libstdc++
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fdd1476b000)
Now Swift should work without the error in question.
Do you have a non standard install using a PPA or any libraries for the build chain built from source? Particularly libstdc++. Please see my answer for Swift on Linux: Make very first step work.

Ubuntu gcc compile errors

When I compile my program with the command
gcc -o ****** -Xlinker -Bstatic -L/usr/lib -lf2c -lm
an error occurs
usr/bin/ld: cannot find -lgcc_s
Who can tell me the way to solve this error? The version of my system is 32bit Ubuntu 13.04, gcc 4.6. And I had searched the error,somebody said it maybe the error of symlink, but it has the link of /usr/lib/libgcc_s.so to /lib/i386-linux-gnu/libgcc_s.so.1 on my system. I also setted system variable LD_LIBRARY_PATH=/lib/i386-linux-gnu, but it did not work.
It is happening when I add -Bdynamic to the command,gcc compile successfully.The commands of compiling program with archive library and dynamic library are different.Maybe it is the explanation of "cannot find -lgcc_s"