-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add flags to link main programs with C/C++ main
#896
Conversation
src/fpm_targets.f90
Outdated
! If the main program is on a C/C++ source, the Intel Fortran compiler requires option | ||
! -nofor-main to avoid "duplicate main" errors. | ||
! https://stackoverflow.com/questions/36221612/p3dfft-compilation-ifort-compiler-error-multiple-definiton-of-main | ||
if (model%compiler%is_intel() .and. any(exe_type==[FPM_TARGET_C_OBJECT,FPM_TARGET_CPP_OBJECT])) then | ||
if (get_os_type()==OS_WINDOWS) then | ||
targets(size(targets))%ptr%compile_flags = '/nofor-main' | ||
else | ||
targets(size(targets))%ptr%compile_flags = '-nofor-main' | ||
end if | ||
end if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we put this in the compiler type to provide us with extra link / compile flags?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep - done. Unfortunately after that location the link between the .exe
target and the fact that it comes from a C/C++ source is lost (two separate targets are made: the object and the executable), so, I can't call for the flags from elsewhere, but at least it's better coded.
Sorry for the many more commits - I believe I've hit a compiler bug with strings that kept working on my unit but failed on the CI.
move main flags to `compiler_t` fix char allocation debugging prints default init use subroutine, not function no fortran no empty string use temporary variable use associate
c16c453
to
90cfb2e
Compare
Please let me know if this is a reasonable solution, so I can go back to working on Intel-MPI on #859 |
Added flags for |
@perazz Looks good to me. |
Thank you @arteevraina. Any more comments @egiovan? Otherwise, I think this can be merged. |
-nofor-main
flag to Intel linking main programs with C/C++ sourcemain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @perazz , Looks good to me.
If there are no more comments, I will merge later today. |
Merging now. |
Address #895. I believe this slight change should be enough for now.