diff --git a/m4/ax_mexopts.m4 b/m4/ax_mexopts.m4 index 8c1150287..52c750581 100644 --- a/m4/ax_mexopts.m4 +++ b/m4/ax_mexopts.m4 @@ -60,8 +60,10 @@ case ${MATLAB_ARCH} in # Also note that the -lssp must come by the end of the link command # (otherwise it will have to be enclosed within --whole-archive). MATLAB_LIBS="-lmex -lmx -lmat -lmwlapack -lmwblas -Wl,-Bstatic -lssp -Wl,-Bdynamic" - # Hack for static linking of libgomp, needed for OpenMP - OPENMP_LDFLAGS="-Wl,-Bstatic,--whole-archive -lgomp -Wl,-Bdynamic,--no-whole-archive" + # Hack for static linking of libgomp, needed for OpenMP. + # Should come by the end of the link command + # (otherwise it will have to be enclosed within --whole-archive). + OPENMP_LIBS="-Wl,-Bstatic -lgomp -Wl,-Bdynamic" ax_mexopts_ok="yes" ;; maci64) @@ -129,5 +131,5 @@ AC_SUBST([MATLAB_CXXFLAGS]) AC_SUBST([MATLAB_FCFLAGS]) AC_SUBST([MATLAB_LDFLAGS]) AC_SUBST([MATLAB_LIBS]) -AC_SUBST([OPENMP_LDFLAGS]) +AC_SUBST([OPENMP_LIBS]) ]) diff --git a/mex/build/kronecker.am b/mex/build/kronecker.am index ac07bb602..9308edf08 100644 --- a/mex/build/kronecker.am +++ b/mex/build/kronecker.am @@ -4,7 +4,7 @@ nodist_sparse_hessian_times_B_kronecker_C_SOURCES = sparse_hessian_times_B_krone nodist_A_times_B_kronecker_C_SOURCES = A_times_B_kronecker_C.f08 matlab_mex.F08 blas_lapack.F08 sparse_hessian_times_B_kronecker_C_CXXFLAGS = $(AM_CXXFLAGS) -fopenmp -sparse_hessian_times_B_kronecker_C_LDFLAGS = $(AM_LDFLAGS) $(OPENMP_LDFLAGS) +sparse_hessian_times_B_kronecker_C_LDADD = $(OPENMP_LIBS) BUILT_SOURCES = $(nodist_sparse_hessian_times_B_kronecker_C_SOURCES) $(nodist_A_times_B_kronecker_C_SOURCES) CLEANFILES = $(nodist_sparse_hessian_times_B_kronecker_C_SOURCES) $(nodist_A_times_B_kronecker_C_SOURCES) diff --git a/mex/build/local_state_space_iterations.am b/mex/build/local_state_space_iterations.am index e9281345f..ddff330da 100644 --- a/mex/build/local_state_space_iterations.am +++ b/mex/build/local_state_space_iterations.am @@ -5,7 +5,7 @@ nodist_local_state_space_iteration_3_SOURCES = local_state_space_iteration_3.f08 nodist_local_state_space_iteration_k_SOURCES = local_state_space_iteration_k.f08 local_state_space_iteration_2_CXXFLAGS = $(AM_CXXFLAGS) -fopenmp -local_state_space_iteration_2_LDFLAGS = $(AM_LDFLAGS) $(OPENMP_LDFLAGS) +local_state_space_iteration_2_LDADD = $(OPENMP_LIBS) local_state_space_iteration_3_FCFLAGS = $(AM_FCFLAGS) -I../libkordersim -pthread local_state_space_iteration_3_LDADD = ../libkordersim/libkordersim.a diff --git a/mex/build/perfect_foresight_problem.am b/mex/build/perfect_foresight_problem.am index 2c186d815..6046a09c2 100644 --- a/mex/build/perfect_foresight_problem.am +++ b/mex/build/perfect_foresight_problem.am @@ -6,8 +6,7 @@ nodist_perfect_foresight_problem_SOURCES = perfect_foresight_problem.cc DynamicM perfect_foresight_problem_CPPFLAGS = $(AM_CPPFLAGS) -I$(TOPDIR) perfect_foresight_problem_CXXFLAGS = $(AM_CXXFLAGS) -fopenmp -perfect_foresight_problem_LDFLAGS = $(AM_LDFLAGS) $(OPENMP_LDFLAGS) -perfect_foresight_problem_LDADD = $(LIBADD_DLOPEN) +perfect_foresight_problem_LDADD = $(LIBADD_DLOPEN) $(OPENMP_LIBS) BUILT_SOURCES = $(nodist_perfect_foresight_problem_SOURCES) CLEANFILES = $(nodist_perfect_foresight_problem_SOURCES) diff --git a/mex/build/qmc_sequence.am b/mex/build/qmc_sequence.am index 5ee862dae..2cb09b2bf 100644 --- a/mex/build/qmc_sequence.am +++ b/mex/build/qmc_sequence.am @@ -4,7 +4,7 @@ TOPDIR = $(top_srcdir)/../../sources/sobol qmc_sequence_CPPFLAGS = $(AM_CPPFLAGS) -I$(TOPDIR) qmc_sequence_CXXFLAGS = $(AM_CXXFLAGS) -fopenmp -qmc_sequence_LDFLAGS = $(AM_LDFLAGS) $(OPENMP_LDFLAGS) +qmc_sequence_LDADD = $(OPENMP_LIBS) nodist_qmc_sequence_SOURCES = qmc_sequence.cc