Fortran Coarray cant compile - fortran

Im trying to compile an example of Coarray Fortran file.
https://github.com/ljdursi/coarray-examples
The command for compile is:
mpifort diffusion/diffusion-coarray.f90 -fcoarray=lib -o diffusion/diffusion-coarray -L ${PATH_TO_OPENCOARRAY_LIB} -lcaf_mpi
I've already installed the OpenCoarrays, using spack
But there is an error:
/usr/bin/ld: cannot find -lcaf_mpi
collect2: error: ld returned 1 exit status
Without -lcaf_mpi the error is:
/tmp/ccOdrmfc.o: In function `MAIN__':
diffusion-coarray.f90:(.text+0x32): undefined reference to `_gfortran_caf_num_images'
diffusion-coarray.f90:(.text+0x4c): undefined reference to `_gfortran_caf_this_image'
diffusion-coarray.f90:(.text+0x66): undefined reference to `_gfortran_caf_this_image'
diffusion-coarray.f90:(.text+0x77): undefined reference to `_gfortran_caf_num_images'
diffusion-coarray.f90:(.text+0x8a): undefined reference to `_gfortran_caf_num_images'
diffusion-coarray.f90:(.text+0xaa): undefined reference to `_gfortran_caf_this_image'
diffusion-coarray.f90:(.text+0xbd): undefined reference to `_gfortran_caf_this_image'
diffusion-coarray.f90:(.text+0xf4): undefined reference to `_gfortran_caf_num_images'
End etc.
Where is the problem?

Thanks for help. I've solved the problem. If anyone will be interested, here is my solution:
1. Install Linuxbrew following their instructions:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"
test -d ~/.linuxbrew && PATH="$HOME/.linuxbrew/bin:$HOME/.linuxbrew/sbin:$PATH"
test -d /home/linuxbrew/.linuxbrew && PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:$PATH"
test -r ~/.bash_profile && echo "export PATH='$(brew --prefix)/bin:$(brew --prefix)/sbin'":'"$PATH"' >>~/.bash_profile
echo "export PATH='$(brew --prefix)/bin:$(brew --prefix)/sbin'":'"$PATH"' >>~/.profile
Install OpenCoarrays library brew install opencoarrays
Now we can compile files with caf and cafrun
Compile .exe-file caf fname.f90 -o test.exe
Run the program cafrun -np (numimages) test.exe
Hope it will be helpful for someone!
P.S. My OS is Ubuntu 16.04.4 LTS, gfortran: GNU Fortran 5.4.0 20160609 so the rest of necessary tools (for example, compiler caf and launcher cafrun are the part of OpenCoarrays package) will be installed by following the instruction.

Related

How to integrate and run C and C++ Codes in VS Code after installing mingw? Error is coming

I first installed mingw into my system and added it to the path. It worked. Showing version when I type gcc --version in cmd.
Then I reinstalled VS Code, then installed C/C++ Intellisense Extension and Code Runner Extension into the VS Code.
After that, when I am writing even simple Hello World Programs, it is displaying an error as follows.
PS E:\C Programming> cd "e:\C Programming\" ; if ($?) { gcc hello-world.c -o hello-world } ; if ($?) { .\hello-world }
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../libmingw32.a(main.o):(.text.startup+0xc0): undefined reference to `WinMain#16'
collect2.exe: error: ld returned 1 exit status
PS E:\C Programming>
What does all this mean? Please Help me fix this!

quantlib multithreading/enable-sessions build error on Linux

Getting below errors after compiling quantlib 1.9.2 with boost 1.5.4 on Fedora 20 with enable-sessions flag, and running one of the examples, any ideas?
cd QuantLib-1.9.2/
nohup ./configure --enable-sessions --enable-thread-safe-observer-pattern &
tail -f nohup.out
nohup make &
tail -f nohup.out
cp ql/.libs/libQuantLib.so.0.0.0 /lib64/libQuantLib.so
cp ql/.libs/libQuantLib.so.0.0.0 /lib64/libQuantLib.so.0
cd Examples/BermudanSwaption
g++ BermudanSwaption.cpp -o BermudanSwaption -lQuantLib
/usr/lib/gcc/x86_64-redhat-linux/4.8.3/../../../../lib64/libQuantLib.so:
undefined reference to `pthread_mutexattr_destroy'
undefined reference to `QuantLib::sessionId()'
undefined reference to `pthread_mutexattr_init'
undefined reference to `boost::system::system_category()'
undefined reference to `pthread_mutexattr_settype'
undefined reference to `boost::system::generic_category()'
collect2: error: ld returned 1 exit status
Note: Im trying to enable sessions since getting segfault when quantlib is used in multi-threaded client application
answering my own question
1) the pthread and boost_system error disappeared after adding -lboost_system flag to compiler command line:
g++ BermudanSwaption.cpp -o BermudanSwaption -lQuantLib -lboost_system
this helped: undefined reference to boost::system::system_category() when compiling
2) to solve sessionId error I added sessionId function in BermudanSwaption.cpp as suggested here under QL_ENABLE_SESSIONS: https://github.com/lballabio/QuantLib/blob/master/ql/userconfig.hpp
"You will have to provide and link with the library a sessionId()
function in namespace QuantLib, returning a different session id
for each session"
after I commented out #if defined(QL_ENABLE_SESSIONS) in BermudanSwaption.cpp it compiled without errors:
//#if defined(QL_ENABLE_SESSIONS)
namespace QuantLib {
Integer sessionId() { return 0; }
}
//#endif

cURL cross compile

How can I cross compile "cURL" for windows on linux(actually using kali)? Or is there a linux distro where the cross compile environment is already built or where the cross compile environment is simple to build?
Please Help!
I have Mingw working fine with header files already in its include directory. Now I compiled cURL and verified its existence in Mingw's include directory. But now when I include <curl/curl.h> in my code, this is the error I will get during compile time:
/tmp/ccsrpc1o.o:https.c:(.text+0x1c): undefined reference to `__imp__curl_global_init'
/tmp/ccsrpc1o.o:https.c:(.text+0x26): undefined reference to `__imp__curl_easy_init'
/tmp/ccsrpc1o.o:https.c:(.text+0x4a): undefined reference to `__imp__curl_easy_setopt'
/tmp/ccsrpc1o.o:https.c:(.text+0x5a): undefined reference to `__imp__curl_easy_perform'
/tmp/ccsrpc1o.o:https.c:(.text+0x73): undefined reference to `__imp__curl_easy_strerror'
/tmp/ccsrpc1o.o:https.c:(.text+0xb2): undefined reference to `__imp__curl_easy_cleanup'
/tmp/ccsrpc1o.o:https.c:(.text+0xbc): undefined reference to `__imp__curl_global_cleanup'
collect2: ld returned 1 exit status
First cross compile cURL with these commands:
$ ./configure --host=i586-mingw32msvc --enable-http --with-zlib --with-winssl
$ make
$ make install
And you can now compile your code(s):
$ i586-mingw32msvc-gcc -o https.exe https.c -lcurl
or
$ i586-mingw32msvc-gcc -o https.exe https.c /usr/i586-mingw32msvc/lib/libcurl.dll.a

How can I compile a C++ program with root library includes using g++?

I have written a C++ program (mainPixelDet1.C that uses a class defined in PixelDet1.C), that works in root's interactive mode.
But now I want to compile it outside root, using g++.
Here's what I write on the Terminal:
g++ -o main mainPixelDet1.C PixelDet1.C `root-config --cflags --glibs`
And here's what I get:
/usr/bin/ld: cannot find -lGraf3d
usr/bin/ld: cannot find -lPostscript
/usr/bin/ld: cannot find -lPhysics
collect2: error: ld returned 1 exit status
You'll have to also include --ldflags to root-config, so that root-config will supply the necessary library flag arguments.
I had the same problem and I just solved it installing these libraries: "libroot-*", "root-plugin-*","ttf-root-installer".`
I find the answer on ROOT forum if you interested, here is the link:
https://root.cern.ch/phpBB3/viewtopic.php?t=16352.
To install the library, you can write on terminal the follow command line:
sudo apt-get install nameoflibrary

Compile C++ and OpenSSL on Ubuntu 11.10

I got a serious problem compiling my C++ and OpenSSL project on my Ubuntu 11.10.
The compiling command is:
g++ -Wall -lssl -lm -lcrypto -I ./src ./src/server.cpp -o ./bin/server
I receive these errors:
server.cpp:(.text+0x8ff): undefined reference to `RSA_new'
server.cpp:(.text+0x92d): undefined reference to `PEM_read_RSAPrivateKey'
server.cpp:(.text+0xa85): undefined reference to `RSA_size'
server.cpp:(.text+0xaa1): undefined reference to `RSA_size'
server.cpp:(.text+0xae7): undefined reference to `RSA_private_decrypt'
server.cpp:(.text+0xd84): undefined reference to `BF_set_key'
server.cpp:(.text+0xf1d): undefined reference to `BF_ecb_encrypt'
server.cpp:(.text+0x13c6): undefined reference to `BF_ecb_encrypt'
collect2: ld returned 1 exit status
make: *** [server] Error 1
I successfully installed openssl and libssl-dev but the problem persists.
I tried to compile the project on Linux Mint 12 with the kernel 3.0 and I had the same problem.
On my old Linux OS with the kernel 2.6 the project compiled and worked fine (using the same Makefile and the same sources).
Please help me!
Generally you need to have the -l link flags after the code that references them. Try
g++ -Wall -I ./src ./src/server.cpp -o ./bin/server -lssl -lm -lcrypto
As the comment to this answer states, the linker only looks for undefined symbols to include in the order the parameters are listed.
That is, if your cpp file uses the libraries, the libraries have to be listed after the cpp file.
Those error are from crypto library, check whether ssl and crypto libraries are available in /usr/lib or where ever u installed if not install them and have u set the library search path for libssl and libcrypto in your compiling command?