Hello,
I have a project that I build on Windows and Linux. Most of the targets work for both platforms, but one of them needs winsocks when compiled on Windows.
I want to avoid having two targets, so I wanted to ask what is the best/recommended way of dealing with this situation?
I tried adding the winsocks to "Other linker options" using the $if(){}{} command:
$if("OS == Windows"){-lws2_32}{}, but did not find any way to write the OS == Windowscondition.
At the end, I just created a custom compiler variable WINSOCKS=ws2_32 in my Windows installation of C::B and use the following test:
$if($WINSOCKS){-l$WINSOCKS}{}. This works for me, but it will fail for anyone else who will try to build the project on Windows, without the variable defined..
So, my question is, is there a better way?
As a side note, the target file prepends three libraries to the project settings:
PocoDataMySQL, mysqlclient, and ws2_32 (in this order). If I have the first two as "Link libraries" and winsocks in "Other linker options", the linker gets
-lws2_32 -lPocoDataMySQL -lmysqlclient, i.e., winsocks goes first ... which does not work. As a result, I have to move the other two libraries to "Other linker options" - not really an issue, just that I would expect "other options" to go at the end.