dfranx / SHADERed

Lightweight, cross-platform & full-featured shader IDE
https://shadered.org/
MIT License
4.33k stars 272 forks source link

Compiling on mac #41

Closed kirkegaard closed 4 years ago

kirkegaard commented 4 years ago

Has anyone successfully compiled on mac? I can kind of get to here but its having some trouble when trying to locate assimp. Ive installed assimp through brew.

...
[100%] Linking CXX executable bin/SHADERed
ld: library not found for -lassimp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/SHADERed] Error 1
make[1]: *** [CMakeFiles/SHADERed.dir/all] Error 2
make: *** [all] Error 2
$ ls -la /usr/local/lib/libassimp*
lrwxr-xr-x 48 christian 26 Dec  0:13 /usr/local/lib/libassimp.5.0.0.dylib -> ../Cellar/assimp/5.0.0/lib/libassimp.5.0.0.dylib
lrwxr-xr-x 44 christian 26 Dec  0:13 /usr/local/lib/libassimp.5.dylib -> ../Cellar/assimp/5.0.0/lib/libassimp.5.dylib
lrwxr-xr-x 42 christian 26 Dec  0:13 /usr/local/lib/libassimp.dylib -> ../Cellar/assimp/5.0.0/lib/libassimp.dylib
lrwxr-xr-x 42 christian 26 Dec 11:49 /usr/local/lib/libassimp.dylib.5 -> ../Cellar/assimp/5.0.0/lib/libassimp.dylib
dfranx commented 4 years ago

@kirkegaard as far as I know, no. Few people were trying to but I haven't heard from them in a long time.

Unfortunately, I can't help with issues on Mac devices since I do not have access to one.

Maybe try this though: https://github.com/ros-planning/geometric_shapes/issues/23#issuecomment-284830221

That's as much as I can help though, I have zero experience with macOS. Hopefully someone else can help with this. I would absolutely love to provide binaries for macOS too...

kirkegaard commented 4 years ago

Thank you! I'll give it a try and let you know if i have any luck with this :)

nanjizal commented 4 years ago

You might be able to maintain mac via travis or similar. https://docs.travis-ci.com/user/languages

prime31 commented 4 years ago

I'm getting close to a macos compile. First off, you need to install all deps with brew (or however you like to install stuff): brew install glm glew assimp

Now I'm onto actually modifying the source. Current issue is the plugin loader failing, so I'll start by hacking that sucker out:


PluginManager.cpp:461:72: error: use of undeclared identifier 'HINSTANCE'
                                DestroyPluginFn fnDestroyPlugin = (DestroyPluginFn)GetProcAddress((HINSTANCE)m_proc[i], "DestroyPlugin");
``
dfranx commented 4 years ago

Thank you so much for helping! Yeah, I've checked the PluginManager code now and it seems that I do the following:

#if defined(__linux__) || defined(__unix__)
   linux code
#else
   windows code
#endif

which means that you are trying to compile Win32 API code on the macos. Oops, my fault, I guess I haven't thought about macos while writing that code.

prime31 commented 4 years ago

Yup, so far my changes are in PluginManager:

#if defined(__linux__) || defined(__unix__) changes to #if defined(__linux__) || defined(__unix__) || defined(__APPLE__)

That gets PluginManager to compile at least. Next up is the CodeEditorUI which has some misplaced #ifs that end up with macos having a missing brace. Trudging forward...

prime31 commented 4 years ago

Victory

Screen Shot 2020-02-25 at 12 35 48 PM
prime31 commented 4 years ago

So, I had to modify CMakeLists.txt:

In CodeEditorUI I got a bit lazy and just gutted all the #if blocks out instead of properly diagnosing the missing paren.

dfranx commented 4 years ago

Congrats and thank you for doing this! It looks absolutely lovely on macos! Is everything working properly - the debugger, HLSL projects, etc...? Though, some things aren't implemented on macos - one being the "Recompile on file change" option, couldn't write the code cause I couldn't test the end result.

Also, thank you for describing the things you've changed, I'll apply these things in the next commit!

prime31 commented 4 years ago

I havent tested much yet but adding some objects and compiling GLSL shaders definitely works. I'll poke around some more when I have some time.

kirkegaard commented 4 years ago

Oh wow! This is amazing! Thank you so much! Im so testing this tonight

intvoker commented 4 years ago

Keep in mind that there is the issue with find_package(GLEW REQUIRED) in recent versions of cmake: https://gitlab.kitware.com/cmake/cmake/issues/19662

So, for example, build fails with cmake 3.16.4. Builds fine with cmake 3.13.2.

bagobor commented 4 years ago

@dfranx It's better to redo project dependencies to use either conan or cmake fetch. will be much less painful to develop on different platforms.
If you not against this I can create a PR then.
And I do have access to Win,OSX,Linux environments )

Calinou commented 4 years ago

@bagobor vcpkg seems to be getting more traction than Conan when it comes to C++ dependency management. Either way, this is a discussion for another issue :slightly_smiling_face:

tanis2000 commented 4 years ago

I've submitted a PR with a working version on macOS

https://github.com/dfranx/SHADERed/pull/60

prime31 commented 4 years ago

@tanis2000 to the rescue!

tanis2000 commented 4 years ago

@tanis2000 to the rescue!

That's my bread and butter :)

dfranx commented 4 years ago

Thank you so much for the pull request! I tested it and merged it to master. I guess I can close this issue now.

Johnhersh commented 4 years ago

I get this error while building on MacOS:

[ 1%] Built target glslang-default-resource-limits [ 2%] Built target OGLCompiler [ 3%] Built target OSDependent [ 4%] Built target SPVRemapper [ 8%] Built target HLSL [ 24%] Built target glslang [ 52%] Built target ShaderDebugger [ 57%] Built target SPIRV [ 59%] Built target spirv-remap [ 60%] Built target glslangValidator [ 61%] Linking CXX executable ../bin/SHADERed ld: library not found for -lassimp.5 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: [../bin/SHADERed] Error 1 make[1]: [CMakeFiles/SHADERed.dir/all] Error 2 make: *** [all] Error 2

Anyone knows why? The packages are all installed via brew, so I'm not sure what's going on.

tanis2000 commented 4 years ago

@Johnhersh brew install assimp Should solve this

kirkegaard commented 4 years ago

@Johnhersh Sounds like you havent updated your cmake cache file. Try deleting CMakeCache.txt and run cmake again

Johnhersh commented 4 years ago

@tanis2000 that didn't work unfortunately :/ Installing assimp returns:

Warning: assimp 5.0.1 is already installed and up-to-date To reinstall 5.0.1, run brew reinstall assimp

Which I tried reinstalling it and just got the same result again. But I'm a bit confused because the error says that lassimp cannot be found, not assimp. Are those the same then?

@kirkegaard deleting that file in the build directory and then running make -j8 recreates the cmakecache file and gives the same error that lassimp could not be found

Anyone has any other ideas?

kirkegaard commented 4 years ago

Cmakecache is generated by cmake. You gotta run cmake before make

Johnhersh commented 4 years ago

@kirkegaard I see, that's where I made a mistake. So I deleted the CMakeCache.txt file and this time it did get to 100%, but then gave me the exact same error as before.

I'm really confused by the extra l in lassimp, is that a separate library than assimp?

kirkegaard commented 4 years ago

Just to be sure, whats your current HEAD?

Johnhersh commented 4 years ago

@kirkegaard I'm not quite sure what you mean? But if you mean which branch I pulled from GitHub it's SHADERED-master

kirkegaard commented 4 years ago

Okay just wanted to make sure you're on the latest and greatest. If cmake doesn't give you any errors it should've found the library so it seems weird that make will tell you otherwise

Johnhersh commented 4 years ago

I do see a warning in cmake:

-- Found GLEW: /usr/local/include
CMake Warning (dev) at /usr/local/lib/cmake/assimp-5.0/assimpTargets.cmake:54 (if): if given arguments:

"ON"

An argument named "ON" appears in a conditional statement. Policy CMP0012 is not set: if() recognizes numbers and boolean constants. Run "cmake --help-policy CMP0012" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Call Stack (most recent call first): /usr/local/lib/cmake/assimp-5.0/assimp-config.cmake:1 (include) CMakeLists.txt:146 (find_package) This warning is for project developers. Use -Wno-dev to suppress it.

tanis2000 commented 4 years ago

@Johnhersh we are on the same version of assimp:

$ brew info assimp
assimp: stable 5.0.1 (bottled), HEAD

I do have the same warning as you because that's in assimb's cmake configuration:

$ cmake ../
-- The C compiler identification is AppleClang 11.0.0.11000033
-- The CXX compiler identification is AppleClang 11.0.0.11000033
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning (dev) at /usr/local/lib/cmake/assimp-5.0/assimpTargets.cmake:54 (if):
  if given arguments:

    "ON"

  An argument named "ON" appears in a conditional statement.  Policy CMP0012
  is not set: if() recognizes numbers and boolean constants.  Run "cmake
  --help-policy CMP0012" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.
Call Stack (most recent call first):
  /usr/local/lib/cmake/assimp-5.0/assimp-config.cmake:1 (include)
  CMakeLists.txt:147 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found SFML .. in /usr/local/include
-- Google Mock was not found - tests based on that will not build
-- spirv-tools not linked - illegal SPIRV may be generated for HLSL
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/tanis/Documents/SHADERed/build

But I can successfully compile it with make -j8 then. The fact that you see -lassimp.5 is ok because that's how the command line linking is built.

Can you remove everything in the build folder, go into it and run cmake ../ and paste here the full output please?

Johnhersh commented 4 years ago

After deleting the build folder and running cmake from scratch, this is the output:

$ cmake ../
-- The C compiler identification is AppleClang 11.0.0.11000033
-- The CXX compiler identification is AppleClang 11.0.0.11000033
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found GLM: /usr/local/include  
-- Found OpenGL: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/OpenGL.framework   
-- Found GLEW: /usr/local/include  
CMake Warning (dev) at /usr/local/lib/cmake/assimp-5.0/assimpTargets.cmake:54 (if):
  if given arguments:

    "ON"

  An argument named "ON" appears in a conditional statement.  Policy CMP0012
  is not set: if() recognizes numbers and boolean constants.  Run "cmake
  --help-policy CMP0012" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.
Call Stack (most recent call first):
  /usr/local/lib/cmake/assimp-5.0/assimp-config.cmake:1 (include)
  CMakeLists.txt:146 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found SFML .. in /usr/local/include
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.7.3", minimum required is "3") 
-- Google Mock was not found - tests based on that will not build
-- spirv-tools not linked - illegal SPIRV may be generated for HLSL
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE  
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/johnher/Downloads/SHADERed-master/SHADERed/build
Johnhersh commented 4 years ago

Here's the log from the make:

https://pastebin.com/DTU55zQc

xinaesthete commented 4 years ago

Similar situation here.

adrianogil commented 4 years ago

I am also having some issues on master (5c51731), but commit 1115fb1 is working fine for me.

xinaesthete commented 4 years ago

@adrianogil which version of macOS is that on? For me, I managed to build from master (would need to check which exact revision) but only after upgrading to Catalina - so if you have a configuration that works on an older version I'd be marginally interested to know.

neelmewada commented 2 years ago

Hello guys! Can you please share the compiled macOS app if it's possible? That'd be super helpful. Thanks!

Brett-StrayThought commented 2 months ago

Is the current master building for people on macOS? I'm currently getting errors. Any help greatly appreciated.

brett@Bretts-M3-Max build % cmake ../
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- The C compiler identification is AppleClang 15.0.0.15000309
-- The CXX compiler identification is AppleClang 15.0.0.15000309
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /opt/homebrew/bin/pkg-config (found version "0.29.2")
-- Found OpenGL: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/System/Library/Frameworks/OpenGL.framework
-- Found GLEW: /opt/homebrew/lib/cmake/glew/glew-config.cmake
-- Found GLM: /opt/homebrew/include
CMake Error at CMakeLists.txt:165 (add_subdirectory):
  The source directory

    /Users/brett/Documents/Development/C/SHADERed/libs/SpvGenTwo

  does not contain a CMakeLists.txt file.

CMake Error at CMakeLists.txt:172 (add_subdirectory):
  The source directory

    /Users/brett/Documents/Development/C/SHADERed/libs/assimp

  does not contain a CMakeLists.txt file.

CMake Error at CMakeLists.txt:177 (add_subdirectory):
  The source directory

    /Users/brett/Documents/Development/C/SHADERed/libs/glslang

  does not contain a CMakeLists.txt file.

CMake Error at CMakeLists.txt:180 (add_subdirectory):
  The source directory

    /Users/brett/Documents/Development/C/SHADERed/libs/SPIRV-VM

  does not contain a CMakeLists.txt file.

CMake Deprecation Warning at libs/cppdap/CMakeLists.txt:16 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- Configuring incomplete, errors occurred!
Brett-StrayThought commented 2 months ago

Adding a reply to my comment above in case somebody else finds their way here.

The issue I had was the submodules are not found. I'm new to submodule usage so I didn't know an additional command was required to fetch the submodules. It's mentioned in the ReadMe under Building section where it does the clone and includes:

git clone https://github.com/dfranx/SHADERed.git
cd SHADERed
git submodule update --init

By habit I cloned via the GitHub code menu so I missed this part. So I simply needed to run the following command to get it to fetch the submodules:

git submodule update --init

Then is was able to run the build. When compiling I got an error for libs/cppdap/include/dap/io.h:78:37: error: unknown type name 'FILE'. I had to add the following line to io.h at line 21:

#include <cstdio>    // FILE

Then everything compiled and I got a binary. It runs and then dies:

UNSUPPORTED (log once): POSSIBLE ISSUE: unit 0 GLD_TEXTURE_INDEX_2D is unloadable and bound to sampler type (Float) - using zero texture because texture unloadable

But progress :-)