fortran 90 gfortran fatal error can't rename module file exists - module

I'm trying to compile and run a fortran 90 code with gfortran on a windows 7 machine.
When I compile and link using
gfortran -I"myDir" -g -Wall -Wextra -pedantic -fimplicit-none -fbacktrace -fcheck=all -Wuninitialized
-Q -J"bin" parametricStudy.f90 -o LDCP
I get the following error:
Fatal Error: Can't rename module file 'bin/initializeubcs_mod.mod0' to 'bin/init
ializeubcs_mod.mod': File exists
If I delete the mod file in the folder 'bin', then it compiles without any problems, but I don't want to have to delete all of my .mod files in the folder every time I compile my code. What should I do?
Any help is greatly appreciated!

If you're using gfortran 4.9 or 4.9.1 I guess you're being bit by https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62215 . In that case, please update to 4.9.2 where this issue is fixed.

Related

SDL2 doesn't compile on macos Big Sur

In one of my projects I'm using git submodules to download the SDL2 Library and compile it. This is giving me a strange error so I tried to compile SDL2 Standalone and I got the same error.
I'm on a 13" MacBook Pro Big Sur
Steps to reproduce:
git clone https://github.com/libsdl-org/SDL.git
cd SDL
cmake . -Bbuild
make -C ./build
The error I get is
In file included from /Users/<user>/Documents/side side projects/neural networks/libs/SDL/src/file/cocoa/SDL_rwopsbundlesupport.m:24:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:12:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSBundle.h:91:143: error: function does not return NSString
- (NSAttributedString *)localizedAttributedStringForKey:(NSString *)key value:(nullable NSString *)value table:(nullable NSString *)tableName NS_FORMAT_ARGUMENT(1) NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0));
~~~~~~~~~~~~~~ ^ ~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:103:48: note: expanded from macro 'NS_FORMAT_ARGUMENT'
#define NS_FORMAT_ARGUMENT(A) __attribute__ ((format_arg(A)))
^ ~
1 error generated.
make[2]: *** [libs/SDL/CMakeFiles/SDL2.dir/src/file/cocoa/SDL_rwopsbundlesupport.m.o] Error 1
make[1]: *** [libs/SDL/CMakeFiles/SDL2.dir/all] Error 2
make: *** [all] Error 2
The message would imply that Apple's own SDK files don't compile, but that can't be right. What's even stranger is that I'm using git submodules with SDL2 in another project but that compiles successfully and I can't find any discernible difference between this and the other project.
Edit:
I user make -C ./build VERBOSE=1 to compare the output with the project that successfully compiled and the project that failed to compile.
Successfully compiled:
[ 0%] Building C object libs/SDL/CMakeFiles/SDL2.dir/src/file/cocoa/SDL_rwopsbundlesupport.m.o
cd "/Users/<user>/Documents/side side projects/Legion/build/libs/SDL" && /usr/local/opt/llvm/bin/clang -DSDL2_EXPORTS -DUSING_GENERATED_CONFIG_H -I"/Users/<user>/Documents/side side projects/Legion/build/libs/SDL/include" -I"/Users/<user>/Documents/side side projects/Legion/libs/SDL/include" -g -O3 -idirafter "/Users/<user>/Documents/side side projects/Legion/libs/SDL/src/video/khronos" -D_THREAD_SAFE -msse3 -msse2 -msse -m3dnow -mmmx -Wshadow -fvisibility=hidden -Wdeclaration-after-statement -Werror=declaration-after-statement -fno-strict-aliasing -Wall -fPIC -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks -o CMakeFiles/SDL2.dir/src/file/cocoa/SDL_rwopsbundlesupport.m.o -c "/Users/<user>/Documents/side side projects/Legion/libs/SDL/src/file/cocoa/SDL_rwopsbundlesupport.m"
Take note of: -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/System/Library/Frameworks
Failed to compile:
[ 0%] Building C object CMakeFiles/SDL2.dir/src/file/cocoa/SDL_rwopsbundlesupport.m.o
/usr/local/opt/llvm/bin/clang -DSDL2_EXPORTS -DUSING_GENERATED_CONFIG_H -I/Users/<user>/Desktop/SDL-main/build/include -I/Users/<user>/Desktop/SDL-main/include -idirafter "/Users/<user>/Desktop/SDL-main/src/video/khronos" -I/usr/local/Cellar/libusb/1.0.24/include/libusb-1.0 -D_THREAD_SAFE -msse3 -msse2 -msse -m3dnow -mmmx -Wshadow -fvisibility=hidden -Wdeclaration-after-statement -Werror=declaration-after-statement -fno-strict-aliasing -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk -mmacosx-version-min=11.5 -fPIC -o CMakeFiles/SDL2.dir/src/file/cocoa/SDL_rwopsbundlesupport.m.o -c /Users/<user>/Desktop/SDL-main/src/file/cocoa/SDL_rwopsbundlesupport.m
Take note of: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk
The only difference between the successfully compiled project and the project that failed to compile is the MacOS SDK version. The one that failed to compile used MacOS SDK 12 while the successful one used MacOS 11.3. Until this is fixed a temporary solution is to downgrade your MacOS SDK to 11.3.

Why is my MakeFile path setup getting a "No such file or directory" error?

I am trying to run a makefile. I think the makefile is trying to access this path:
/home/s/miniconda3/lib/python3.7/site-packages/tensorflow/include/unsupported/Eigen
But when I run it, I get a No such file or directory error:
(base) s#s-VirtualBox:~/Downloads/3d-psrnet-master$ make
make: Circular utils/tf_ops/cd/tf_nndistance_g.cu <- utils/tf_ops/cd/tf_nndistance_g.cu.o dependency dropped.
/usr/local/cuda-10.1/bin/nvcc -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11 -c -o utils/tf_ops/cd/tf_nndistance_g.cu.o utils/tf_ops/cd/tf_nndistance_g.cu -I /home/s/miniconda3/lib/python3.7/site-packages -DGOOGLE_CUDA=1 -x cu -Xcompiler -fPIC -O2
utils/tf_ops/cd/tf_nndistance_g.cu:3:10: fatal error: include/unsupported/Eigen: No such file or directory
#include "include/unsupported/Eigen"
^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [makefile:12: utils/tf_ops/cd/tf_nndistance_g.cu.o] Error 1
I have it set like this at the top of makefile: tensorflow = /home/s/miniconda3/lib/python3.7/site-packages (which is the path that shows up if I type into Terminal pip show tensorflow)
And then in tf_nndistance_g.cu I have:
#include "include/unsupported/Eigen/"
What might be the reason that this makefile isn't working? I'm using Python 3.7 on a Virtual Machine (ubuntu Virtualbox). Thanks.

How can fix Access Noxim installation Error

Plz Help what is the error when I run the "make"
g++ -g -O3 -I. -I.. -I../src -I/usr/local/systemc-2.3.2/include/systemc-2.2 -c ../src/NoximNoC.cpp
../src/NoximNoC.cpp:14:10: fatal error: systemc.h: No such file or directory
14 | #include <systemc.h>
| ^~~~~~~~~~~
compilation terminated.
make: *** [Makefile.defs:26: ../src/NoximNoC.o] Error 1
Welcome to StackOverflow :-)
systemc.h: No such file or directory
That's the core error here. Maybe that file is indeed not present on your system, or your make toolchain can't find it. Please try the advice in https://stackoverflow.com/a/43375326/4341322.

gfortran cannot read its own creation

I am trying to compile a code with gfortran. One of the first things that happens in the compilation is the creation of constants.mod. Soon after that gfortran tells me:
Fatal Error: Cannot read module file ‘constants.mod’ opened at (1), because it was created by a different version of GNU Fortran
Now here's the thing: This module file is created by the same gfortran that it's trying to read it. gfortran creates the thing itself and then 1 second later thinks the file was created by some other version! Any idea what's going on here?
You'll probably want to see the compile command:
mpif90 -c -O3 -ISDF/FORTRAN/include -I/usr/include -Iobj -Jobj -o obj/shared_data.o src/core/shared_data.F90
shared_data.F90 contains the module constants at the top of the file.
EDIT: Here's the compile command followed by the full error message:
$> mpif90 -c -O3 -ISDF/FORTRAN/include -I/usr/include -Iobj -Jobj -o obj/shared_data.o src/core/shared_data.F90
src/core/shared_data.F90:67:6:
USE constants
1
Fatal Error: Cannot read module file ‘constants.mod’ opened at (1), because it was created by a different version of GNU Fortran
compilation terminated.
UPDATE: I hope you'll agree this is weird. The file that is failing is in src/core. If I cd to src/core and issue this command:
mpif90 -c -O3 -I../../SDF/FORTRAN/include -I../../obj -J../../obj -o ../../obj/shared_data.o shared_data.F90
it compiles just fine! But then I clean everything out of the obj directory and I cd two levels up and issue:
mpif90 -c -O3 -ISDF/FORTRAN/include -Iobj -Jobj -o shared_data.o src/core/shared_data.F90
and it fails with the error I showed above! What is the difference??? Thanks.

Unable to compile sharable .o files with g++

When i compile with the following command:
g++ -fPIC -o obj/buffer.o buffer.cpp
I get the following error:
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/crt1.o:
In function _start': (.text+0x20): undefined reference tomain'
I am thought with the -fPIC flag, I didn't need a main function. I get this error with all of the cpp files. I do have a main.cpp that has the shared library functions in it. You can get the source code at the following:
git clone https://github.com/nterry/39DLL-4-Linux.git
Any ideas? I know that I can use the ld binary to put all of the o files in the an so once they're done, I just need help in building them all into shareable .o files
I think that I answered my question. I added a -c to the command and it seems to have worked. Here is the command I used:
g++ -fPIC -c -o obj/list.o list.cpp
That is one of several cpp files, and all seemed to work.