Author Topic: Codebocks on windows link 1561 error using clang  (Read 4880 times)

Offline pabristow

  • Multiple posting newcomer
  • *
  • Posts: 75
Codebocks on windows link 1561 error using clang
« on: March 09, 2018, 07:22:01 pm »
I am trying to use Codebocks 17.12 on Windows 10 (uptodate) with Visual Studio 15.6.1 installed linking to the Boost test library.

I can build and run use of Boost.Test (using a library) using GCC 7.1 (so I am confident that the C++ is correct, and the gcc boost.test library file must be correct).

With Clang 5.0.0 (or the shiny new 6.0.0) I can compile and run programs that do not try to *link* to any Boost libraries.

I hve these extra compiler includes
C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include

When I try an example of using Boost.Test library, it compiles OK

but fails to link 1561 error using Clang 5 (or the shiny new 6).
(This is said to mean is lacking a main() which is provided by the Boost.test program).

Is this expected? Target: x86_64-pc-windows-msvc

(On gcc 7.2.0 --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 )

Anybody with (good) experience of using Clang on Codeblocks on Windows with suggestions?

Thanks

Paul

PS Complete failing message is

-------------- Build: clang500_Release in hello_boost_test (compiler: LLVM Clang 5.0.0 Compiler)---------------

clang++.exe  -o bin\Release\hello_test.exe obj\Release\hellos\hello_boost_test\hello_boost_test.o  -m64 -v  I:\modular-boost\lib\libboost_unit_test_framework-clang50-mt-x64-1_66.lib
clang version 5.0.0 (tags/RELEASE_500/final)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\LLVM\clang-500\LLVM\bin
 "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Professional\\VC\\Tools\\MSVC\\14.13.26128\\bin\\HostX64\\x64\\link.exe" "-out:bin\\Release\\hello_test.exe" -defaultlib:libcmt "-libpath:C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Professional\\VC\\Tools\\MSVC\\14.13.26128\\lib\\x64" "-libpath:C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.16299.0\\ucrt\\x64" "-libpath:C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.16299.0\\um\\x64" -nologo "obj\\Release\\hellos\\hello_boost_test\\hello_boost_test.o" "I:\\modular-boost\\lib\\libboost_unit_test_framework-clang50-mt-x64-1_66.lib"
clang++.exe: error: linker command failed with exit code 1561 (use -v to see invocation)
LINK : fatal error LNK1561: entry point must be defined




Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Codebocks on windows link 1561 error using clang
« Reply #1 on: March 09, 2018, 07:36:51 pm »
a full rebuild log would be a beginning... This is only a partial log.

Offline pabristow

  • Multiple posting newcomer
  • *
  • Posts: 75
Re: Codebocks on windows link 1561 error using clang
« Reply #2 on: March 13, 2018, 06:59:35 pm »

-------------- Clean: clang500_Release in hello_boost_test (compiler: LLVM Clang 5.0.0 Compiler)---------------

Cleaned "hello_boost_test - clang500_Release"

-------------- Build: clang500_Release in hello_boost_test (compiler: LLVM Clang 5.0.0 Compiler)---------------

clang++.exe -Wall -fexceptions -m64 -v -fms-extensions -Wall -fms-compatibility-version=19.10 -II:\modular-boost -II:\modular-boost -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0" -I"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include" -c J:\Cpp\hellos\hello_boost_test\hello_boost_test.cpp -o obj\Release\hellos\hello_boost_test\hello_boost_test.o
clang++.exe  -o bin\Release\hello_test.exe obj\Release\hellos\hello_boost_test\hello_boost_test.o  -m64 -v  I:\modular-boost\lib\libboost_unit_test_framework-clang50-mt-x64-1_66.lib
clang version 5.0.0 (tags/RELEASE_500/final)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\LLVM\clang-500\LLVM\bin
 "C:\\LLVM\\clang-500\\LLVM\\bin\\clang++.exe" -cc1 -triple x86_64-pc-windows-msvc19.10.0 -emit-obj -mrelax-all -mincremental-linker-compatible -disable-free -disable-llvm-verifier -discard-value-names -main-file-name hello_boost_test.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -momit-leaf-frame-pointer -v -dwarf-column-info -debugger-tuning=gdb -coverage-notes-file "J:\\Cpp\\hello_test\\obj\\Release\\hellos\\hello_boost_test\\hello_boost_test.gcno" -resource-dir "C:\\LLVM\\clang-500\\LLVM\\lib\\clang\\5.0.0" -I "I:\\modular-boost" -I "I:\\modular-boost" -I "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.16299.0" -I "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\include" -internal-isystem "C:\\LLVM\\clang-500\\LLVM\\lib\\clang\\5.0.0\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\include" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.10586.0\\ucrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.10586.0\\shared" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.10586.0\\um" -Wall -Wall -fdeprecated-macro -fdebug-compilation-dir "J:\\Cpp\\hello_test" -ferror-limit 19 -fmessage-length 0 -fms-extensions -fms-compatibility -fms-compatibility-version=19.10 -std=c++14 -fdelayed-template-parsing -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -o "obj\\Release\\hellos\\hello_boost_test\\hello_boost_test.o" -x c++ "J:\\Cpp\\hellos\\hello_boost_test\\hello_boost_test.cpp"
clang -cc1 version 5.0.0 based upon LLVM 5.0.0 default target x86_64-pc-windows-msvc
ignoring duplicate directory "I:\modular-boost"
ignoring duplicate directory "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include"
  as it is a non-system directory that duplicates a system directory
#include "..." search starts here:
#include <...> search starts here:
 I:\modular-boost
 C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0
 C:\LLVM\clang-500\LLVM\lib\clang\5.0.0\include
 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include
 C:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\ucrt
 C:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\shared
 C:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\um
End of search list.
clang version 5.0.0 (tags/RELEASE_500/final)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\LLVM\clang-500\LLVM\bin
 "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Professional\\VC\\Tools\\MSVC\\14.13.26128\\bin\\HostX64\\x64\\link.exe" "-out:bin\\Release\\hello_test.exe" -defaultlib:libcmt "-libpath:C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Professional\\VC\\Tools\\MSVC\\14.13.26128\\lib\\x64" "-libpath:C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.16299.0\\ucrt\\x64" "-libpath:C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.16299.0\\um\\x64" -nologo "obj\\Release\\hellos\\hello_boost_test\\hello_boost_test.o" "I:\\modular-boost\\lib\\libboost_unit_test_framework-clang50-mt-x64-1_66.lib"
clang++.exe: error: linker command failed with exit code 1561 (use -v to see invocation)
LINK : fatal error LNK1561: entry point must be defined
Process terminated with status 1561 (0 minute(s), 2 second(s))
1 error(s), 0 warning(s) (0 minute(s), 2 second(s))
 
Dos this help shed any light on what I am doing wrong?

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Codebocks on windows link 1561 error using clang
« Reply #3 on: March 13, 2018, 10:16:17 pm »
i am honestly a bit confused. I have never done anything with clang... And this error message looks like a msvc error message. Is clang using msvc error messages?

After some googeling this seems to be a problem between console and gui application. What is the signature of your main function?


Some general tip:  by default you can not link libraries between compilers. So if you have compiled boost with gcc you can not use it with clang or msvc. It is even not possible to link between different gcc versions.


Online stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: Codebocks on windows link 1561 error using clang
« Reply #4 on: March 13, 2018, 11:03:31 pm »
Google says "You haven't defined a function named main or wmain or WinMain or  wWinMain."

Edit: I just re-read you first post which stated about what I said above. In using the SDL library you must use just the correct main function signature for it to work; the same thing might be needed here.

Tim S.
« Last Edit: March 13, 2018, 11:36:40 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline pabristow

  • Multiple posting newcomer
  • *
  • Posts: 75
Re: Codebocks on windows link 1561 error using clang
« Reply #5 on: March 14, 2018, 04:26:59 pm »
Yes agreed - I found this on a well-known search engine too.

But I believe I do have a int main() in hello_boost_test

(provided by boost.test macro #define BOOST_TEST_MAIN )

and the same hello_boost_test.cpp source works fine with GCC.

so I suspect something in the Build Options is the cause, but remain puzzled.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Codebocks on windows link 1561 error using clang
« Reply #6 on: March 14, 2018, 08:03:16 pm »
Quote
so I suspect something in the Build Options is the cause, but remain puzzled.
and to fix this we need the signature of this main function

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Codebocks on windows link 1561 error using clang
« Reply #7 on: March 14, 2018, 09:09:51 pm »
What happens if you write manually main function? Does it work?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline pabristow

  • Multiple posting newcomer
  • *
  • Posts: 75
Re: Codebocks on windows link 1561 error using clang
« Reply #8 on: March 15, 2018, 04:04:30 pm »
I'm not sure how to do this.  Boost.Test produces its own entry point with signature

int unit_test_main( init_unit_test_func init_func, int argc, char* argv[] );

and inspecting the result of --save-temp 

"J:\Cpp\hello_test\hello_boost_test.ii"

contains unit_test_main (as does the equivalent when compiling with gcc7.1.0).

I believe that Boost.test provides this as its version of main().  How this works interallyI have yet to understand.

(another test using another linked library works as expected).


Online stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: Codebocks on windows link 1561 error using clang
« Reply #9 on: March 15, 2018, 04:48:06 pm »
You need to post your CB full re-build log to a site that supports the Boost Library.
You also need to post your Compiler, Linker, and Boost library version info on that site to get help.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org