Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings for visual studio #202

Closed
etheaven opened this issue May 3, 2016 · 14 comments
Closed

Settings for visual studio #202

etheaven opened this issue May 3, 2016 · 14 comments

Comments

@etheaven
Copy link

etheaven commented May 3, 2016

Hello, may i know how am i supposed to compile it with visual studio? throws unresolved external symbols, i believe your code is not wrong, it's probably because of the compiler.

@dmah42
Copy link
Member

dmah42 commented May 3, 2016

i'm not sure what you've tried, but this is a good starting point: https://cognitivewaves.wordpress.com/cmake-and-visual-studio/

once you have a solution file, you can build as normal in VS.

what are the symbols? it might be our code :)

@BillyONeal
Copy link
Contributor

If you have unresolved symbols you probably need to add shlwapi.lib to your linker inputs.

@EricWF
Copy link
Contributor

EricWF commented Aug 30, 2016

@BillyONeal Should the CMake be linking shlwapi.lib instead?

@BillyONeal
Copy link
Contributor

@EricWF: Don't know if it is possible to ask cmake to do that. See here:

# We need extra libraries on Windows

The dependency on shlwapi.lib gets injected through a .obj that is packaged inside benchmark.lib (compiled from here), so it needs to be present on the linker command line for anyone who links against benchmark.lib.

@BillyONeal
Copy link
Contributor

(MSVC++ has #pragma comment(lib, "shlwapi.lib"), but I don't believe MinGW supports anything like that; so if folks are using CMake they're better off manually specifying it in their CMakeLists.txt)

@EricWF
Copy link
Contributor

EricWF commented Aug 30, 2016

Thanks Billy. I don't work on Windows so I'm trying to figure out if this is our bug, or just a general quirk of Windows compilation (like -pthread or -lm on Unix). If we ever get a CMake configuration module we should ensure shlwapi.lib is listed as an interface link library.

I think the best course of action is to prominently document the dependency as a known issue and close this bug.

@EricWF EricWF closed this as completed in 61f570e Aug 30, 2016
@EricWF
Copy link
Contributor

EricWF commented Aug 30, 2016

@BillyONeal Patches correctly implementing #pragma comment(lib, "shlwapi.lib") are welcome. I would do it myself but I'm unfamiliar with Windows.

@BillyONeal
Copy link
Contributor

@EricWF: You can just stick that pragma in sysinfo.cc, and that lib will be added as a dependency for anyone who links against the resulting .obj. Putting it after #include <Shlwapi.h> should work:

#include <Shlwapi.h>
-- but as I said I don't think that will work for MinGW targets.

@winstondu
Copy link
Contributor

winstondu commented Nov 25, 2017

@BillyONeal , can you explain to Nooglers who aren't used to using Cmake how I can manually link in Shlwapi into my projects CMakeLists?

Edit: figured it out. Just added "shlwapi.lib" to target_link_library command in my project. (Do add an example line of code, as I went on a wild goose chase to find the physical location of that file not knowing minGW had it on its regular path)

@BillyONeal
Copy link
Contributor

@winstondu In the same target_link_libraries where you add google test, just add shlwapi. I've been doing something like this:

function(add_benchmark BENCHNAME)
  add_executable("${BENCHNAME}" "${PROJECT_SOURCE_DIR}/benchmarks/${BENCHNAME}.cpp")
  target_link_libraries("${BENCHNAME}" benchmark)
  if (MSVC)
    target_link_libraries("${BENCHNAME}" Shlwapi.lib)
  endif()
  add_test("run_${BENCHNAME}" "${BENCHNAME}" "${BENCHMARK_OUTPUT_FORMAT}")
endfunction(add_benchmark)

wesm pushed a commit to apache/arrow that referenced this issue Jan 5, 2018
These changes were necessary to compile on Windows with "-DARROW_BUILD_BENCHMARKS=ON".  I added Shwlapi based on google/benchmark#202.

Author: Adam Seibert <seibs@users.noreply.github.com>

Closes #1406 from seibs/ARROW-1909 and squashes the following commits:

98602cd [Adam Seibert] ARROW-1909: [C++] Enables building with benchmarks on windows
@Cxx-mlr
Copy link

Cxx-mlr commented Oct 10, 2019

Once i build the INSTALL.vcproj and RUN_TESTS , how do i link the library to a new VS project

@ura1286
Copy link

ura1286 commented Oct 15, 2019

@Cxx-mlr I have the same requirement to link the library to a new VS project. Did you get it working yet? If yes, can you please share the steps to do it?

@bstordrup
Copy link
Contributor

If the benchmark project is generated with -DBUILD_SHARED_LIBS=on, it will work in Visual Studio - as long as the Additional Include Directories contain the benchmark/include folder and the Additional Library Directories contain the benchmark/lib folder.

There is no need to specify shlwapi.lib as additional dependency in the consuming project.

I don't think that the version being installed through vcpkg is build with shared libs on - I had to build it specifically off a forked version.

@dmah42
Copy link
Member

dmah42 commented Jan 4, 2024

is there a way to change the vcpkg installer version to include shared libs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants