I am trying to use a fortran library to perform FFT called "2Decomp&FFT"(http://www.2decomp.org/download.html). This library has a in-built FFT engine and works fine with my code. In order to use FFTW3 engine with this library, instead of its in-built engine, the instructions say:
Edit 'src/Makefile.inc' file in 2DECOMP, change the FFT engine to 'FFT=fftw3'. You also need to set the FFTW_PATH variable in the same file to point to your FFTW installation. Then recompile everything.
I installed FFTW3.3 on my local Mac and followed the instructions and recompiled the library. However after that when I am trying to compile my code with the library, I am getting the following error while linking.
Undefined symbols for architecture x86_64:
"_dfftw_destroy_plan_", referenced from:
___decomp_2d_fft_MOD_decomp_2d_fft_finalize in lib2decomp_fft.a(fft_fftw3.o)
"_dfftw_execute_dft_", referenced from:
___decomp_2d_fft_MOD_c2c_1m_z in lib2decomp_fft.a(fft_fftw3.o)
___decomp_2d_fft_MOD_c2c_1m_x in lib2decomp_fft.a(fft_fftw3.o)
___decomp_2d_fft_MOD_c2c_1m_y in lib2decomp_fft.a(fft_fftw3.o)
"_dfftw_execute_dft_c2r_", referenced from:
___decomp_2d_fft_MOD_c2r_1m_x in lib2decomp_fft.a(fft_fftw3.o)
___decomp_2d_fft_MOD_fft_3d_c2r in lib2decomp_fft.a(fft_fftw3.o)
"_dfftw_execute_dft_r2c_", referenced from:
___decomp_2d_fft_MOD_fft_3d_r2c in lib2decomp_fft.a(fft_fftw3.o)
"_dfftw_plan_many_dft_", referenced from:
___decomp_2d_fft_MOD_c2c_1m_z_plan in lib2decomp_fft.a(fft_fftw3.o)
___decomp_2d_fft_MOD_c2c_1m_x_plan in lib2decomp_fft.a(fft_fftw3.o)
___decomp_2d_fft_MOD_c2c_1m_y_plan in lib2decomp_fft.a(fft_fftw3.o)
"_dfftw_plan_many_dft_c2r_", referenced from:
___decomp_2d_fft_MOD_init_fft_engine in lib2decomp_fft.a(fft_fftw3.o)
"_dfftw_plan_many_dft_r2c_", referenced from:
___decomp_2d_fft_MOD_init_fft_engine in lib2decomp_fft.a(fft_fftw3.o)
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [Sora_v71] Error 1
Here is a minimal code I have written which calls this library:
program test
use decomp_2d
use decomp_2d_fft
integer n, pr, pc
call decomp_2d_init(n,n,n,pr,pc)
call decomp_2d_fft_init
stop
end
Here is the Makefile I am using (DECOMP2D is the environment variable set to the folder containing the library) :
## ------------------------------------------------------------------------
# Lines included for using the 2decomp libraries
INC_2DECOMP = -I$(DECOMP2D)/include/
LIB_2DECOMP = -L$(DECOMP2D)/lib/ -l2decomp_fft
## ------------------------------------------------------------------------
RM = rm
SRCDIR = .
LIBDIR = .
BIN = a.out
OBJS = main.o
## ------------------------------------------------------------------------
# default command for compiler, linker
FC = mpif90
FFLAGS = $(F90FLAG) $(INC_2DECOMP)
LFLAGS = $(F90FLAG) $(LIB_2DECOMP) -L$(LIBDIR)
## ------------------------------------------------------------------------
# default action
all: $(BIN)
$(BIN): $(OBJS)
#echo Linking $(BIN) .....
$(FC) $(OBJS) $(LFLAGS) $(FFLAGS) -o $#
.f.o:
#echo Compiling $*.f
$(FC) $(LFLAGS) $(FFLAGS) -c $(SRCDIR)/$*.f
clean:
#echo 'Cleaning .....'
$(RM) -f core *.o *~ *.L *.O $(BIN) $(SIZE_FILE)
Related
Given a very simple fortran (95) function and a very simple c++ call to the program, I should be able to compile the program using:
g++ -c main1.cpp
gfortran -c test.f95
g++ main1.o test.o -o run
However, here I get the following error:
ld: warning: object file (test.o) was built for newer macOS version (11.5) than being linked (11.0)
Undefined symbols for architecture arm64:
"hello_()", referenced from:
_main in main1.o
"__gfortran_st_write", referenced from:
_hello_ in test.o
"__gfortran_st_write_done", referenced from:
_hello_ in test.o
"__gfortran_transfer_character_write", referenced from:
hello in test.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here, adding a -v tag before the -o tag and after the -o tag and the exe run did not solve the problem, as suggested by the error message.
I am currently working on a project using netcdf-c library. I have installed it using Homebrew. I have written a small script to write a .NC file. I am using a Mac
When I compile it in CLion using make main the following gets outputted:
make main
cc main.c -o main
Undefined symbols for architecture x86_64:
"_nc_close", referenced from:
_main in main-f43ab9.o
"_nc_get_var_int", referenced from:
_main in main-f43ab9.o
"_nc_inq_varid", referenced from:
_main in main-f43ab9.o
"_nc_open", referenced from:
_main in main-f43ab9.o
"_nc_strerror", referenced from:
_main in main-f43ab9.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [main] Error 1
This is the content of my Cmakelists.txt:
cmake_minimum_required(VERSION 3.6)
project(hello)
INCLUDE_DIRECTORIES(/usr/local/include)
LINK_DIRECTORIES(/usr/local/lib)
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /usr/local/lib)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} cc -stdlib=lnetcdf -Wall -Werror main.c")
INCLUDE_DIRECTORIES(/usr/local/include)
LINK_DIRECTORIES(/usr/local/lib)
set(SOURCE_FILES main.c)
add_executable(hello ${SOURCE_FILES})
Despite this I am able to execute my code by using the terminal and typing:
cc -lnetcdf main.c
Could someone tell me where the problem is?
Thanks
spent some time, with the big help of other SO user, trying to install Allegro library on osx 10.10.5
Finally it seems like it is ok, so I open the code blocks, pasted the example code( http://partitionseven.blogspot.com/2011/01/compiling-allegro-5-with-mac-os-x-snow.html), and I get an error while copiling
g++ -c /Users/lukasz/Desktop/test_allegro/test.cpp -o /Users/lukasz/Desktop/test_allegro/test.o
g++ -o /Users/lukasz/Desktop/test_allegro/test /Users/lukasz/Desktop/test_allegro/test.o
Undefined symbols for architecture x86_64:
"_al_clear_to_color", referenced from:
__al_mangled_main in test.o
"_al_create_display", referenced from:
__al_mangled_main in test.o
"_al_destroy_display", referenced from:
__al_mangled_main in test.o
"_al_flip_display", referenced from:
__al_mangled_main in test.o
"_al_install_system", referenced from:
__al_mangled_main in test.o
"_al_map_rgb", referenced from:
__al_mangled_main in test.o
"_al_rest", referenced from:
__al_mangled_main in test.o
"_main", referenced from:
implicit entry/start for main executable
(maybe you meant: __al_mangled_main)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
when I follow the tutorial exactly running the code from terminal with
gcc alleg5test.c -o alleg5test -L/usr/local/lib -lallegro -lallegro_main
./alleg5test
it works- i got a black screen. But how do I make it work from Code Blocks?
I am trying to re-build a simple GCC plugin (which builds fine on GNU Linux).
I am intending to compile the plugin using GNU GCC v4.6.3 which I have already installed under Mac OS X.
The Makefile contents are given below:
GCC=/Users/xxx/compilers/gcc-4.6.3/install/bin/gcc
PLUGIN_SOURCE_FILES= plugin.c
PLUGIN_OBJECT_FILES= $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
GCCPLUGINS_DIR= $(shell $(GCC) -print-file-name=plugin)
CFLAGS+= -I$(GCCPLUGINS_DIR)/include -I/Users/xxx/compilers/gcc-4.6.3/install/include - I/Users/xxx/compilers/gcc-4.6.3/gcc/ -fPIC -O0 -g3
plugin.so: $(PLUGIN_OBJECT_FILES)
$(GCC) -shared $^ -o $#
plugin.o:plugin.c
$(GCC) $(CFLAGS) -I$(GCCPLUGINS_DIR) -c $^ -o $#
clean:
rm *.o *.so
I am getting the following error:
Undefined symbols for architecture x86_64:
"_register_callback", referenced from:
_plugin_init in plugin_base.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [plugin_base.so] Error 1
GCC compiler is built using the following configuration:
../gcc-4.6.3/configure --prefix=/Users/xxx/compilers/gcc-4.6.3/install/ --program-suffix=-4.6.3.x --enable-languages=c,c++ --disable-multilib --enable-cloog-backend=isl --with-gmp=/Users/xxx/compilers/gcc-4.6.3/install/ --with-mpfr=/Users/xxx/compilers/gcc-4.6.3/install/ --with-mpc=/Users/xxx/compilers/gcc-4.6.3/install/ --with-ppl=/Users/xxx/compilers/gcc-4.6.3/install/ --with-cloog=/Users/xxx/compilers/gcc-4.6.3/install/
Had the same problem, hit this page without answers. Decided to continue digging. Found the answer on a Sourceforge page from 2008.
Instead of linking with gcc -shared ..., use gcc -dynamiclib -undefined dynamic_lookup ...
So in your example,
$(GCC) -shared $^ -o $#
should be replaced with
$(GCC) -dynamiclib -undefined dynamic_lookup $^ -o $#
Also, found that this homebrew formula was actually able to install GCC 4.6 on Mac OS X 10.10.
Helllo, I have some code, that I'm trying to compile. The code runs well on Linux but I can't compile it on OSX.
In the makefile I use for Linux:
LD_FLAGS = -lcudart -L$(CUDA_HOME)/lib64
For Mac I try to use these flags:
LD_FLAGS = -lcudart -L$(CUDA_HOME)/lib
LD_FLAGS = -lm -F/Library/Frameworks -framework CUDA
CXXFLAGS = -O3 -g -m32 -I$(CUDA_HOME)/include
NVCC_FLAGS = -O3 -g -G -I$(CUDA_HOME)/include -arch=sm_11
This is the make output file:
mpic++ -c -o main.o main.cpp -O3 -m32 -I/Developer/NVIDIA/CUDA-5.0/include
/Developer/NVIDIA/CUDA-5.0/bin/nvcc -c -o kernel.o kernel.cu -O3 -I/Developer/NVIDIA/CUDA-5.0/include -arch=sm_11
ptxas /tmp/tmpxft_000026f4_00000000-5_kernel.ptx, line 146; warning : Double is not supported. Demoting to float
/Developer/NVIDIA/CUDA-5.0/bin/nvcc -c -o support.o support.cu -O3 -I/Developer/NVIDIA/CUDA-5.0/include -arch=sm_11
mpic++ main.o kernel.o support.o -o stencil-mpi -lcudart -L/Developer/NVIDIA/CUDA-5.0/lib
ld: warning: ld: warning: ignoring file kernel.o, file was built for i386 which is not the architecture being linked (x86_64): kernel.o
ignoring file main.o, file was built for i386 which is not the architecture being linked (x86_64): main.o
ld: warning: ignoring file support.o, file was built for i386 which is not the architecture being linked (x86_64): support.o
Undefined symbols for architecture x86_64:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [stencil-mpi] Error 1
This problem was caused by trying to mix 32 and 64 bit compilation between the CUDA and MPI toolchains. It was noted in comments that adding -m64 instead of -m32 for LD_FLAGS, CXXFLAGS, and NVCC_FLAGS produced a working 64 bit build.