MTG / essentia

C++ library for audio and music analysis, description and synthesis, including Python bindings
http://essentia.upf.edu
GNU Affero General Public License v3.0
2.81k stars 525 forks source link

Compiling using native windows Visual Studio compiler #330

Open Tripphippie opened 8 years ago

Tripphippie commented 8 years ago

I'm attempting to build Essentia using Visual studio and native windows tools. I'm not a linux guy and I don't want to setup cygwin and all that nonsense. Would someone be so kind as to send me a copy of essentia_algorithms_reg.cpp that I could use? I'm going to replace the python with something else and I need a template to know what to output. If anyone is interested in native windows builds I might be able to upstream my changes. Also what is up with the RogueVector class. The methods that access private members of std::vector won't compile but I think with swap semantics and the c++11 compiler features you shouldn't have to use the rogueVector at all.

moebiussurfing commented 4 years ago

hey @maxgraf96, I do not have tried yet to compile by myself. Maybe I'll try someday... But in my case it could be hard, bc I should need to update the OF addon too...and I don't know if I have enough skills or too much time.

BTW if somebody can share the dll/lib would be nice!

maxgraf96 commented 4 years ago

Alright, if you ever do let me know, I'll post some updates here in case I can get it to work! But for now it looks like it's pretty much impossible with VS...

q-depot commented 4 years ago

to build in VS you need to:

all these changes should be in my fork: https://github.com/q-depot/essentia/commits/python_win

The build instructions mentioned by @dbogdanov are a good starting point

@moebiussurfing some of your errors are missing dependencies, I compiled my library without that stuff, just use the minimum dependencies, there should be an option for "lightweight" build.

@dbogdanov would be great if you could check at those changes in my repo and merge

hosaka commented 3 years ago

@q-depot Any hits as to what should be done with the RogueVector? Neither the OS_WIN32 elif nor the commented out OS_LINUX version compile. I am using the MTG/essentia repo and the python_win branch, which looks to be the as your fork.

Also, were you able to reduce the static lib size in the end? 800mb is not useable for the hardware I am planning to run it on.

KyrillosL commented 3 years ago

Hi @q-depot & @hosaka I'm also struggling at compiling an Essentia.lib (or a .dll) that could be used later with Visual Studio (2017) under Windows 10.

When trying to compile with only one algorithm (MonoLoader), it still compiles 38 algos, including the streaming and freesound algorithms. Here is my command in the x64 command prompt : python3 waf configure --mode=release --build-static --lightweight=libav,libsamplerate --fft=KISS --msvc_targets="x64" --include-algos=MonoLoader --static-dependencies

It doesn't find my 3rd parties dependencies, even if they are in the folder.

Thanks!

Edit : Installing pkgconfiglite through chocolatey solved my problem.

KyrillosL commented 3 years ago

Hi, I managed to get a .dll and a .lib, but I can't link to my project under visual studio.

After setting ESSENTIA_EXPORTS to 0 in the config.h file as recommended previously, I get this unresolved external symbol error : LNK2001 unresolved external symbol "__declspec(dllimport) public: static class essentia::standard::Algorithm * __cdecl essentia::EssentiaFactory<class essentia::standard::Algorithm>::create(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class essentia::Parameter const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class essentia::Parameter const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class essentia::Parameter const &)" (__imp_?create@?$EssentiaFactory@VAlgorithm@standard@essentia@@@essentia@@SAPEAVAlgorithm@standard@2@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0AEBVParameter@2@0101@Z)

I've tried with different flags (debug/release/reduced dependencies), but I can't manage to get it linked properly. Does anyone found a workaround ? Thanks !

VitaMusic commented 2 years ago

I'm interested in well working .lib and .dll of Essentia compiled for Visual Studio 2019, Windows 7, x64 is it possible to use MKL when compiled ?

moebiussurfing commented 2 years ago

yes, should be nice that some successful compiled files can be shared to download...

imiskolee commented 2 years ago

@k

Hi @q-depot & @hosaka I'm also struggling at compiling an Essentia.lib (or a .dll) that could be used later with Visual Studio (2017) under Windows 10.

When trying to compile with only one algorithm (MonoLoader), it still compiles 38 algos, including the streaming and freesound algorithms. Here is my command in the x64 command prompt : python3 waf configure --mode=release --build-static --lightweight=libav,libsamplerate --fft=KISS --msvc_targets="x64" --include-algos=MonoLoader --static-dependencies

It doesn't find my 3rd parties dependencies, even if they are in the folder.

Thanks!

Edit : Installing pkgconfiglite through chocolatey solved my problem.

did you successful compile it on windows use waf?

goloskokovic commented 2 years ago

@imiskolee

https://github.com/MTG/essentia/issues/330#issuecomment-581362303

dbogdanov commented 2 years ago

The python_win branch has been updated further, cherry-picking from @q-depot and with other modifications.

imiskolee commented 2 years ago

@imiskolee

#330 (comment)

thanks, hte prebuilding lib includes all third party depencies ?

yyf commented 2 years ago

@dbogdanov do you know if anyone gets Essentia running in streaming mode on Windows 10 using VisualStudio-built lib or dll? Not sure what's the latest with https://github.com/MTG/essentia/issues/204 ?

Thanks.

goloskokovic commented 2 years ago

@yyf I can confirm running streaming MFCC example: https://github.com/goloskokovic/essentiaMSVC

yyf commented 2 years ago

@goloskokovic thanks for your example! My python waf configures successfully but python waf fails at [260/260] Linking build\src\essentia.dll There are warning messages like cl: Command line warning D9025: overriding /w wutg /W3 and with verbose output (waf -v) it complains about ... warning C4661: ... no suitable definition provided for explicit template instaniation request and lots of messages in red, for example, ... \algorithm.cpp.1.o is created more than once... The task generators are..., If you think that this is an error, set no-errcheck_out on the task instance Build failed -> task in _essentia failed with exit status 2: {task ...: cxx essentia.cpp -> essentia.cpp.1.o} Lastly with more verbose (waf -v -v) the last red message complains about File "waf", line 165 in <module>... Scripting.waf_entry_point(cwd, VERSION, wafdir)... Did you see this before when you first built the MFCC example? My python waf config step passes except there are three python3 items not found: python-config, library python3.7in $prefix/libs, and library python3.7m in $prefix/libs.

Thanks.

goloskokovic commented 2 years ago

@yyf Just use prebilt essentia.lib provided in that repo with headers

yyf commented 2 years ago

@goloskokovic I tried to build the MFCC example with your prebuilt essentia.lib but got lots of linker errors (716): LNK2038 mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in ...obj LNK2005 ... already defined in essentia.lib... ... LNK1120 90 unresolved externals Maybe I miss something?

goloskokovic commented 2 years ago

Be sure to link 3rdparty libs https://github.com/MTG/essentia/issues/330#issuecomment-581362303

https://stackoverflow.com/questions/7668200/error-lnk2038-mismatch-detected-for-iterator-debug-level-value-0-doesnt

In short you are probably mixing release and debug

yyf commented 2 years ago

@goloskokovic Finally got it compiled. My MFCC (and other examples) execute fine without error, but they don't output any result/file for some reason. It doesn't behave like the MFCC example in the prebuilt extractor binaries, where it logs "...start processing... writing results to file..." Ever seen this before?

goloskokovic commented 2 years ago

@yyf Try running it from the Command Prompt: MFCC.exe mfcc.wav mfcc.yaml

yyf commented 2 years ago

@goloskokovic Works now. Had some typo in my debug setting. Thanks again.

WindowsNT commented 2 years ago

So, do we have some static library for x64 and x86 for Visual Studio? Or (better), a DLL.

moebiussurfing commented 2 years ago

So, do we have some static library for x64 and x86 for Visual Studio? Or (better), a DLL.

maybe could use this one? https://github.com/MTG/essentia/issues/330#issuecomment-581362303

andreaagostini commented 2 years ago

Hi, I'm trying to build a minimalistic version of Essentia, with no dependencies, on Visual Studio 2022. I can't use dbogdanov's build because I need it to be built with /MD (Multithreaded DLL) rather than /MT (Multithreaded static library). I'm stumbilng onto the RogueVector thing, too. I understand that some of you (@dbogdanov, @q-depot) have found a working fix for this, but I must be missing something as I'm not finding it in your repos... Any hint about this?

moebiussurfing commented 2 years ago

Hi, I'm trying to build a minimalistic version of Essentia, with no dependencies, on Visual Studio 2022. I can't use dbogdanov's build because I need it to be built with /MD (Multithreaded DLL) rather than /MT (Multithreaded static library). I'm stumbilng onto the RogueVector thing, too. I understand that some of you (@dbogdanov, @q-depot) have found a working fix for this, but I must be missing something as I'm not finding it in your repos... Any hint about this?

there where some python projects to compile if I not remember bad. There's some big file (700mb) shared around here too, a lib to download or something. I do not tried again, but i'm still interested on this. if you get success post it here please.

jamiebullock commented 1 year ago

Hi, I'm trying to build a minimalistic version of Essentia, with no dependencies, on Visual Studio 2022. I can't use dbogdanov's build because I need it to be built with /MD (Multithreaded DLL) rather than /MT (Multithreaded static library). I'm stumbilng onto the RogueVector thing, too. I understand that some of you (@dbogdanov, @q-depot) have found a working fix for this, but I must be missing something as I'm not finding it in your repos... Any hint about this?

@andreaagostini Out of interest, how are you setting the CRT config? The only way I can see to do it is via CXXFLAGS, something like set CXXFLAGS="/MD" && waf configure