diff --git a/configure b/configure
index 6c42c5b445162ce4c71a99a1a21655055ee6e3f6..c7f8767a34c8039730c1a127ebe970b84fa37c9e 100755
--- a/configure
+++ b/configure
@@ -7196,7 +7196,7 @@ EOF
       test -n "$testlib" && comment=" with library $testlib"
       { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $name can link a C++ object$comment" >&5
 $as_echo_n "checking whether $name can link a C++ object$comment... " >&6; }
-      $compexe $LDFLAGS $testlib $LIBS conftest.o conftest-main.o -o conftest.exe 1>/dev/null 2>/dev/null
+      $compexe conftest.o conftest-main.o $LDFLAGS $testlib $LIBS -o conftest.exe 1>/dev/null 2>/dev/null
       if test -f conftest.exe
       then
         found=yes
diff --git a/configure.ac b/configure.ac
index 309c1dd5dcde39a94b4412ba29f5d0e670cdc035..8c76f4ece96ad3ca598e5168e314e78304758261 100644
--- a/configure.ac
+++ b/configure.ac
@@ -803,7 +803,7 @@ EOF
       comment=
       test -n "$testlib" && comment=" with library $testlib"
       AC_MSG_CHECKING([whether $name can link a C++ object$comment])
-      $compexe $LDFLAGS $testlib $LIBS conftest.o conftest-main.o -o conftest.exe 1>/dev/null 2>/dev/null
+      $compexe conftest.o conftest-main.o $LDFLAGS $testlib $LIBS -o conftest.exe 1>/dev/null 2>/dev/null
       if test -f conftest.exe
       then
         found=yes