mirror of
https://github.com/TREX-CoE/Sherman-Morrison.git
synced 2024-12-26 14:23:47 +01:00
Solved linking problem by including C++ standard library '-lstdc++'. Also added a minimal working example of Fortran-C++ interfacing in dir 'mwe'.
This commit is contained in:
parent
84fffdb7fa
commit
f1641dd4e4
14
Makefile
14
Makefile
@ -1,8 +1,8 @@
|
|||||||
CXX=icpc
|
CXX = icpc
|
||||||
CXXFLAGS=-O0 -debug full -traceback
|
CXXFLAGS = -O0 -debug full -traceback
|
||||||
FC=ifort
|
FC = ifort
|
||||||
FFLAGS=-O0 -debug full -traceback
|
FFLAGS = -O0 -debug full -traceback
|
||||||
# ARCH=-xCORE-AVX2
|
# ARCH = -xCORE-AVX2
|
||||||
|
|
||||||
## Deps & objs for the C++ stuff
|
## Deps & objs for the C++ stuff
|
||||||
cppDEPS = cppmain.cpp SM_MaponiA3.cpp SM_MaponiA3.hpp Helpers.hpp
|
cppDEPS = cppmain.cpp SM_MaponiA3.cpp SM_MaponiA3.hpp Helpers.hpp
|
||||||
@ -11,6 +11,8 @@ cppOBJ = cppmain.o SM_MaponiA3.o
|
|||||||
## Deps & objs for the Fortran stuff
|
## Deps & objs for the Fortran stuff
|
||||||
fDEPS = fmain.f90 SM_MaponiA3_mod.f90
|
fDEPS = fmain.f90 SM_MaponiA3_mod.f90
|
||||||
fOBJ = SM_MaponiA3.o SM_MaponiA3_mod.o fmain.o
|
fOBJ = SM_MaponiA3.o SM_MaponiA3_mod.o fmain.o
|
||||||
|
fLIBS = -lstdc++
|
||||||
|
|
||||||
|
|
||||||
## Compile recipes for C++ stuff
|
## Compile recipes for C++ stuff
|
||||||
%.o: %.cpp $(cppDEPS)
|
%.o: %.cpp $(cppDEPS)
|
||||||
@ -36,4 +38,4 @@ cppSherman-Morrison: $(cppOBJ)
|
|||||||
|
|
||||||
## Linking Fortran example program calling the C++ function 'Sherman_Morrison()'
|
## Linking Fortran example program calling the C++ function 'Sherman_Morrison()'
|
||||||
fSherman-Morrison: $(fOBJ)
|
fSherman-Morrison: $(fOBJ)
|
||||||
$(FC) $(ARCH) $(FFLAGS) -o $@ $^
|
$(FC) $(ARCH) $(FFLAGS) $(fLIBS) -o $@ $^
|
||||||
|
1
mwe/compile.sh
Executable file
1
mwe/compile.sh
Executable file
@ -0,0 +1 @@
|
|||||||
|
icpc -c worker.cpp && ifort -c main.f90 && ifort -lstdc++ worker.o main.o -o test
|
12
mwe/main.f90
Normal file
12
mwe/main.f90
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
program test
|
||||||
|
use iso_c_binding
|
||||||
|
implicit none
|
||||||
|
|
||||||
|
interface
|
||||||
|
subroutine hello() bind(C, name="worker")
|
||||||
|
end subroutine
|
||||||
|
end interface
|
||||||
|
|
||||||
|
call hello()
|
||||||
|
|
||||||
|
end program test
|
7
mwe/worker.cpp
Normal file
7
mwe/worker.cpp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#include "worker.h"
|
||||||
|
|
||||||
|
void worker()
|
||||||
|
{
|
||||||
|
std::cout << "Hello, World!" << std::endl;
|
||||||
|
}
|
||||||
|
|
6
mwe/worker.h
Normal file
6
mwe/worker.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
void worker();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user