samples icon indicating copy to clipboard operation
samples copied to clipboard

Add Windows CMake instructions

Open fedorovmichael opened this issue 4 years ago • 6 comments

Hi, I try to run the example as is and after running cmake command running the command make and getting error: make: *** No targets specified and no makefile found

fedorovmichael avatar May 31 '20 05:05 fedorovmichael

By default, cmake on Windows generates a VSCode solution file. You should be able to pass cmake the appropriate flags to generate an appropriate Makefile, but I'm not a CMake expert.

domesticmouse avatar Jun 01 '20 08:06 domesticmouse

but it from your example: https://github.com/dart-lang/samples/tree/master/ffi

Readme: Building native libraries Each sample uses CMake to generate a Makefile. To build the native library for each sample:

cd hello_world/hello_library cmake . make The make command creates a libhello.dylib (macOS), libhello.dll (Windows) or libhello.so (Linux) library file.

fedorovmichael avatar Jun 01 '20 08:06 fedorovmichael

@domesticmouse By passing <-G "Unix Makefiles"> flag with cmake command, we can generate appropriate makefiles for "make" command, but using it in this way, the path of generated dynamic library will be "..\hello_library\libhello.dll" instead of "..\hello_library\Debug\hello.dll" as expected by the code. So, either we can change path in code or use visual studio to build sln file. However, the documentation for windows must be update in either case.

MrUnfunny avatar Oct 23 '20 07:10 MrUnfunny

Running make in windows is not so trivial as in Linux. Here are the steps:

  • Run cmake .. This will create a visual studio project structure.
  • Double click on hello_library.vcxproj to open with visual studio (you should have visual studio installed, community version works just fine)
  • Default build option is debug, change it to release
  • Click Build or press F7

You should find 4 files including hello.dll in a newly created Release folder.

function1983 avatar Feb 06 '22 18:02 function1983

Hello! I'm trying to do what the READ.ME explains but it is not working. Somebody can help-me? I just copy the project called "Hello World", my code is exactly the same.

victorruandev avatar Aug 04 '22 12:08 victorruandev

Also this one @cbracken.

domesticmouse avatar Sep 01 '23 03:09 domesticmouse