After invoking .\vcpkg install celero:x64-windows-static, I tried to use this library. But it didn't work.
(1)
Firstly, the compilation failed: 'unistd.h': No such file or directory. I could solve this problem by adding #define WIN32 before including the Celero header, but I'm not sure if I really should manually adding this. But I guess this could be a problem of the library, not vcpkg.
(2)
After this WIN32 things, now I got a bunch of link errors. It says that several dllimport-ed functions are not resolved, even though I chose static linking. Fortunately, adding #define CELERO_STATIC before including the Celero header made those error messages gone. Again I guess this might be a problem of the library, not vcpkg, though.
(3)
Even after that, the linking still has failed. It doesn't complain about DLL things, but it still says that there are lots of unresolved external symbols....
After doing .\vcpkg install celero:x64-windows-static, the celero.lib file was placed in the directory (vcpkg directory)\installed\x64-windows-static\static\. Since I considered this behavior is somewhat unusual, I tired to copy the celero.lib back to the directory (vcpkg directory)\installed\x64-windows-static\. And then... the linking problem solved!
I don't know why this happens, but I think there must be some problem in CMake files or something.
xmm ..
no error
vcpkg install celero:x64-windows-static
The following packages will be built and installed:
celero[core]:x64-windows-static
Starting package 1/1: celero:x64-windows-static
Building package celero[core]:x64-windows-static...
-- Downloading https://github.com/DigitalInBlue/Celero/archive/9f41c21e35b04d7d65dcb0aff4c962f6e5f2cbc3.tar.gz...
-- Extracting source E:/tools/vcpkg/downloads/DigitalInBlue-Celero-9f41c21e35b04d7d65dcb0aff4c962f6e5f2cbc3.tar.gz
-- Using source at E:/tools/vcpkg/buildtrees/celero/src/f6e5f2cbc3-13e48e53c5
-- Configuring x64-windows-static
-- Building x64-windows-static-dbg
-- Building x64-windows-static-rel
-- Installing: E:/tools/vcpkg/packages/celero_x64-windows-static/share/celero/copyright
-- Performing post-build validation
-- Performing post-build validation done
Building package celero[core]:x64-windows-static... done
Installing package celero[core]:x64-windows-static...
Installing package celero[core]:x64-windows-static... doneInstalling package celero[core]:x64-windows-static... done
Elapsed time for package celero:x64-windows-static: 2.942 min
Total elapsed time: 2.942 min
The package celero:x64-windows-static provides CMake targets:
find_package(celero CONFIG REQUIRED)
target_link_libraries(main PRIVATE celero)
Invoking the install command works fine. But actually using the library, doesn't work.
?
adding #define CELERO_STATIC before including the Celero header made those error messages gone.
vcpkg\installedx64-windows-static \include\celero
Can you do that?
#include "celero\Celero.h"
@Voskrese I'm sorry, I couldn't understand what you mean.
I mean the following code doesn't work:
````
CELERO_MAIN
BASELINE(SomeTest, Baseline, samples, iterations)
{
// Some operations
}
BENCHMARK(SomeTest, Benchmark, samples, iterations)
{
// Some operations
}
To make it work, I needed to modify the above to:
CELERO_MAIN
BASELINE(SomeTest, Baseline, samples, iterations)
{
// Some operations
}
BENCHMARK(SomeTest, Benchmark, samples, iterations)
{
// Some operations
}
```
That's what I wrote in (1) and (2).
And it still doesn't work. To make it finally work, I needed to manually move the compiled library file (celero.lib`) to a different directory. That's what I wrote in (3).
Thanks!
I am mistake. ;) The Main thing is that everything is well ended
Um... is it? Though I could locally handle the problem myself, I think this (wrong location of celero.lib) is certainly a bug.
Don't be so categorically, you can suggest changes to the port
@Voskrese I think that is exactly why I opened this issue. :)
windows- static by default WITHOUT integration are not searched
read at least some documentation and use the search, without sarcasm
Linker -> General, set Additional Library Directories
<AdditionalLibraryDirectories>(vcpkg directory)\installed\x64-windows-static\lib<AdditionalLibraryDirectories>
<PreprocessorDefinitions>CELERO_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<AdditionalDependencies>celero.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
http://gigi.nullneuron.net/gigilabs/setting-up-sdl2-with-visual-studio-2015/
https://github.com/Microsoft/vcpkg/blob/master/docs/users/integration.md
in your .vcxproj. We recommend adding this to the Globals PropertyGroup.
<PropertyGroup Label="Globals">
<!-- .... -->
<VcpkgTriplet Condition="'$(Platform)'=='Win32'">x86-windows-static</VcpkgTriplet>
<VcpkgTriplet Condition="'$(Platform)'=='x64'">x64-windows-static</VcpkgTriplet>
</PropertyGroup>
Um.. sorry, I think it can be possible that we are still misunderstanding each other.
I opened this issue because I thought there is a bug in the Celero port of vcpkg (especially the final .lib file's path), wanted to report about it, and (implicitly) suggested it to be fixed. That is indeed the reason I opened this issue, and I really didn't intend any sarcasm. I'm sincerely sorry if you felt like that.
What I wrote in the first post is what I've done in order to fix the problem I'm facing with, and I was not able to point out where exactly in the CMake file or whatever in the port may have caused the problem, because I don't know about CMake and vcpkg internals quite well, and I was just hoping that those things (description of what I've done) could help figuring out why things had happened.
I have no problem using other libraries with x64-windows-static triplet chosen. I already integrated vcpkg, so other libraries are well searched and linked by the linker without any problem.
The following message is already generated from my VS2017 when I compile my code:
1>Target VcpkgTripletSelection:
1> Using triplet "x64-windows-static" from "(some directory)\vcpkg\installed\x64-windows-static\"
So I think adding
<PropertyGroup Label="Globals">
<!-- .... -->
<VcpkgTriplet Condition="'$(Platform)'=='Win32'">x86-windows-static</VcpkgTriplet>
<VcpkgTriplet Condition="'$(Platform)'=='x64'">x64-windows-static</VcpkgTriplet>
</PropertyGroup>
is not necessary. (And I actually tried it, but it indeed didn't change anything.)
According to the link
https://github.com/Microsoft/vcpkg/blob/master/docs/users/integration.md
you provided, some libraries are explicitly mandated to be manually linked because of some conflicting behaviors. So, perhaps Celero (like other testing libraries) is one of them and what I'm facing with was in fact totally intended. But I don't think so, because of two reasons:
According to the same link, those conflicting libraries are inside manual-link\ directory, not static\ directory. And invoking .\vcpkg owns manual-link does not print anything.
Other projects which do not use Celero didn't have any problem after I moved celero.lib outside the static\ directory.
And if manual linking is not really intended, then how manually adding link dependency can be a "real" solution? I already said that I found a way to handle the problem. Please allow me to repeat this: I'm not asking how to resolve the linking problem; I'm suggesting that there may be a bug in the port, and I want it to be fixed. vcpkg's promise is to allow me not to write those linking options myself. That's why I consider this a bug.
Also, actually, adding
<AdditionalLibraryDirectories>(vcpkg directory)\installed\x64-windows-static\lib<AdditionalLibraryDirectories>
and
<AdditionalDependencies>celero.lib;%(AdditionalDependencies)</AdditionalDependencies>
to the linker even cannot solve the linking problem because celero.lib is NOT in the directory (vcpkg directory)\installed\x64-windows-static\lib.
It actually is in another directory (vcpkg directory)\installed\x64-windows-static\lib\static, and I'm pointing out that this might be a bug.
And I just have realized that I incorrectly wrote these directories in the first post (didn't write \lib part). Maybe this silly mistake of me caused any confusion?
my Microsoft.Cpp.x64.user.props, finds everything without problems
<AdditionalIncludeDirectories>%(ForcedIncludeFiles);%(AdditionalIncludeDirectories);$(VcpkgRoot)\$(VcpkgTriplet)\include;.\include;.\..\include;.\..\..\include</AdditionalIncludeDirectories>
</ClCompile>
<AdditionalLibraryDirectories Condition="'$(Configuration)'=='Debug'">%(AdditionalLibraryDirectories);$(VcpkgRoot)\$(VcpkgTriplet)\debug\lib;.\lib;..\lib</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories Condition="'$(Configuration)'=='Release'">%(AdditionalLibraryDirectories);$(VcpkgRoot)\$(VcpkgTriplet)\lib;.\lib;..\lib</AdditionalLibraryDirectories>
<TargetMachine Condition="'$(Platform)'=='x64'">MachineX64</TargetMachine>
<AdditionalDependencies Condition="'$(Configuration)'=='Debug'">%(AdditionalDependencies);$(VcpkgRoot)\$(VcpkgTriplet)\debug\lib\*.lib</AdditionalDependencies>
<AdditionalDependencies Condition="'$(Configuration)'=='Release'">%(AdditionalDependencies);$(VcpkgRoot)\$(VcpkgTriplet)\lib\*.lib</AdditionalDependencies>
</Link>
...\vcpkg\scripts\buildsystems\msbuild\vcpkg.targets -->>
<VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''"> x64-windows-static
<PropertyGroup Condition="'$(Platform)|$(ApplicationType)|$(ApplicationTypeRevision)' == 'Win64||'">
<VcpkgEnabled Condition="'$(VcpkgEnabled)' == ''">true</VcpkgEnabled>
<VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''">x64-windows-static</VcpkgTriplet>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(VcpkgEnabled)' == 'true'">
<Link>
<AdditionalDependencies Condition="'$(VcpkgNormalizedConfiguration)' == 'Debug' and '$(VcpkgAutoLink)' != 'false'">%(AdditionalDependencies);$(VcpkgRoot)debug\lib\*.lib</AdditionalDependencies>
<AdditionalDependencies Condition="'$(VcpkgNormalizedConfiguration)' == 'Release' and '$(VcpkgAutoLink)' != 'false'">%(AdditionalDependencies);$(VcpkgRoot)lib\*.lib</AdditionalDependencies>
<AdditionalLibraryDirectories Condition="'$(VcpkgNormalizedConfiguration)' == 'Release'">%(AdditionalLibraryDirectories);$(VcpkgRoot)lib;$(VcpkgRoot)lib\manual-link</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories Condition="'$(VcpkgNormalizedConfiguration)' == 'Debug'">%(AdditionalLibraryDirectories);$(VcpkgRoot)debug\lib;$(VcpkgRoot)debug\lib\manual-link</AdditionalLibraryDirectories>
</Link>
<ClCompile>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(VcpkgRoot)include</AdditionalIncludeDirectories>
</ClCompile>
<ResourceCompile>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(VcpkgRoot)include</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
I guess your celero.lib is in the "right" directory ((vcpkg directory)\installed\x64-windows-static\lib) because I can't find any single mention of the "weird" directory (vcpkg directory)\installed\x64-windows-static\lib\static anywhere?
(Note that all the directories appearing in those markup files end with \lib or \lib\manual-link)
If that's the case, that means it is only my machine where celero.lib is generated on a weird directory.
*.lib check and search all lib
$(VcpkgRoot)lib\*.lib</AdditionalDependencies>
If one Lib by name then the full path
(vcpkg directory)\installed\x64-windows-static\lib\static\celero.lib</AdditionalDependencies>
or
(vcpkg directory)\installed\x64-windows-static\lib\static</AdditionalLibraryDirectories>
+
celero.lib</AdditionalDependencies>
<VcpkgTriplet Condition="'$(VcpkgTriplet)' == ''"> x64-windows-static
$(VcpkgRoot)lib\static\celero.lib</AdditionalDependencies>
I still don't quite get your intention. Repeating again, I'm not asking how to resolve the linking problem. The issue is, the correct linking directory is not set by the single command:
.\vcpkg install celero:x64-windows-static
So I explain to you that you have not configured anything for the search to be in a directory with static libraries
What have you done to search was?
vcpkg is not quite a standard build solution, with its scripts and integration
As long as I understood, invoking
.\vcpkg integrate install --triplet x64-windows-static
will automatically configure all supposedly necessary directories. And after that I should be able to just use those .lib files generated by the .\vcpkg install (library-name):x64-windows-static command without touching anything. Am I wrong?
open file ...\vcpkg\scripts\buildsystems\msbuild\vcpkg.targets = integrate
Find something about static in there
_sorry my english, google translate_
If I didn't misunderstand you, so what you are saying is that manually editing ...\vcpkg\scripts\buildsystems\msbuild\vcpkg.targets or something other will solve the problem.
And what I'm saying is this: in my opinion, the fact that I have to do that, is a bug.
This is indeed a port bug and I will fix it in the near future.
After modifying WIN32 to _WIN32 and #ifdef CELERO_STATIC to #if 1, the example code builds successfully.
I used the official sample code on the github homepage.
I did not meet the link error you mentioned.
Hi @jk-jeon, thanks for reporting this issue.
I've fixed it in #10159, please update vcpkg and rebuild celero.
Thanks.
Most helpful comment
windows- static by default WITHOUT integration are not searched
read at least some documentation and use the search, without sarcasm
Linker -> General, set Additional Library Directorieshttp://gigi.nullneuron.net/gigilabs/setting-up-sdl2-with-visual-studio-2015/
https://github.com/Microsoft/vcpkg/blob/master/docs/users/integration.md
in your .vcxproj. We recommend adding this to the Globals PropertyGroup.