Miserlou / RJModules

Various modules for VCV Rack
https://github.com/Miserlou/RJModules
MIT License
99 stars 18 forks source link

Rack v1: Compile failure on Windows (cross-compile) #40

Closed cschol closed 5 years ago

cschol commented 5 years ago

When cross-compiling for Windows on Linux (which is what the build server does), the following issue occurs:

Randoms.cpp.o src/Randoms.cpp
src/EssEff.cpp: In member function ‘std::__cxx11::string EssEff::getAbsolutePath(std::__cxx11::string)’:
src/EssEff.cpp:130:30: error: ‘toWstring’ was not declared in this scope
         std::wstring pathW = toWstring(path);
                              ^~~~~~~~~
src/EssEff.cpp:130:30: note: suggested alternative:
In file included from /home/cschol/src/Rack-1.0/dist/Rack-SDK/include/rack.hpp:6:0,
                 from /home/cschol/src/Rack-1.0/dist/Rack-SDK/include/rack0.hpp:2,
                 from src/RJModules.hpp:1,
                 from src/EssEff.cpp:1:
/home/cschol/src/Rack-1.0/dist/Rack-SDK/include/string.hpp:15:14: note:   ‘rack::string::toWstring’
 std::wstring toWstring(const std::string &s);
              ^~~~~~~~~
src/EssEff.cpp:134:20: error: ‘fromWstring’ was not declared in this scope
             return fromWstring(absPathC);
                    ^~~~~~~~~~~
src/EssEff.cpp:134:20: note: suggested alternative:
In file included from /home/cschol/src/Rack-1.0/dist/Rack-SDK/include/rack.hpp:6:0,
                 from /home/cschol/src/Rack-1.0/dist/Rack-SDK/include/rack0.hpp:2,
                 from src/RJModules.hpp:1,
                 from src/EssEff.cpp:1:
/home/cschol/src/Rack-1.0/dist/Rack-SDK/include/string.hpp:14:13: note:   ‘rack::string::fromWstring’
 std::string fromWstring(const std::wstring &s);
             ^~~~~~~~~~~
Miserlou commented 5 years ago

Should be resolved now.

cschol commented 5 years ago

Still does not compile.

Fix:

diff --git a/src/EssEff.cpp b/src/EssEff.cpp
index 825c7a8..48b6379 100644
--- a/src/EssEff.cpp
+++ b/src/EssEff.cpp
@@ -2,6 +2,9 @@
 #include "osdialog.h"
 #include "common.hpp"
 #include <locale> // for wstring_convert
+#if defined ARCH_WIN
+#include <codecvt>
+#endif
 #include <iostream>
 #include <cmath>
 #include <sstream>
@@ -133,7 +136,7 @@ std::string EssEff::getAbsolutePath(std::string path){
         wchar_t buf[PATH_MAX];
         wchar_t *absPathC = _wfullpath(buf, pathW.c_str(), PATH_MAX);
         if (absPathC)
-            return fromWstring(absPathC);
+            return string::fromWstring(absPathC);
     #endif
     return "";
 }
Miserlou commented 5 years ago

Thanks, you rock! Applied.