Closed Zer0xFF closed 7 years ago
Hi, awesome to hear someone's interested!
I'm definitely interested in a cmake script (haven't used it before though). Send through the PR when you're ready and I'll take a look.
I have made up a quick and dirty Makefile under Linux a while ago so I know it compiles. All those errors make me think the environment includes are wrong, or are you using C instead of the C++ compiler? Not sure really... Try using -v on the compiler command.
I have organised so everything is included relative to PCSX2_Rewrite/PCSX2_Rewrite/Source , for the main project at least, I forgot what the rest are. They should be easy enough to find in the VS project file.
I honestly don't know other than those things. If you're still stuck I have a Mac I can test on next weekend with it.
Good luck, Marco.
this is what I found on the topic, specifically this error.
also, since it's got as far as linkage, the issue wouldn't really be with includes, since that would have failed at compilation, the issue is with the static library missing references, or as the included link explains "Reason: You have to provide the definition of the static member as well as the declaration. The declaration and the initializer go inside the class definition, but the member definition has to be separate.". while this does seem weird to me, i have tested it with 1 variable and it seems to work (seems since the error is not there, an I can only assume, it not just an empty variable)
below is not a clean build, but you still have all the relevant bits, if you'd like the full clean build log, i can do that. I'll try to clean up the script early next week for you to have a look at it as well.
$ make VERBOSE=1
/usr/local/Cellar/cmake/3.7.2/bin/cmake -H/Users/alawi/PCSX2_rewrite/PCSX2_Frontend -B/Users/alawi/PCSX2_rewrite/PCSX2_Frontend/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/Cellar/cmake/3.7.2/bin/cmake -E cmake_progress_start /Users/alawi/PCSX2_rewrite/PCSX2_Frontend/build/CMakeFiles /Users/alawi/PCSX2_rewrite/PCSX2_Frontend/build/CMakeFiles/progress.marks
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/Makefile2 all
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f /Users/alawi/PCSX2_rewrite/PCSX2_Core/build/CMakeFiles/PCSX2_Core.dir/build.make /Users/alawi/PCSX2_rewrite/PCSX2_Core/build/CMakeFiles/PCSX2_Core.dir/depend
cd /Users/alawi/PCSX2_rewrite/PCSX2_Frontend/build && /usr/local/Cellar/cmake/3.7.2/bin/cmake -E cmake_depends "Unix Makefiles" /Users/alawi/PCSX2_rewrite/PCSX2_Frontend /Users/alawi/PCSX2_rewrite/PCSX2_Core /Users/alawi/PCSX2_rewrite/PCSX2_Frontend/build /Users/alawi/PCSX2_rewrite/PCSX2_Core/build /Users/alawi/PCSX2_rewrite/PCSX2_Core/build/CMakeFiles/PCSX2_Core.dir/DependInfo.cmake --color=
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f /Users/alawi/PCSX2_rewrite/PCSX2_Core/build/CMakeFiles/PCSX2_Core.dir/build.make /Users/alawi/PCSX2_rewrite/PCSX2_Core/build/CMakeFiles/PCSX2_Core.dir/build
make[2]: Nothing to be done for `/Users/alawi/PCSX2_rewrite/PCSX2_Core/build/CMakeFiles/PCSX2_Core.dir/build'.
[ 98%] Built target PCSX2_Core
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/PCSX2_ReWrite.dir/build.make CMakeFiles/PCSX2_ReWrite.dir/depend
cd /Users/alawi/PCSX2_rewrite/PCSX2_Frontend/build && /usr/local/Cellar/cmake/3.7.2/bin/cmake -E cmake_depends "Unix Makefiles" /Users/alawi/PCSX2_rewrite/PCSX2_Frontend /Users/alawi/PCSX2_rewrite/PCSX2_Frontend /Users/alawi/PCSX2_rewrite/PCSX2_Frontend/build /Users/alawi/PCSX2_rewrite/PCSX2_Frontend/build /Users/alawi/PCSX2_rewrite/PCSX2_Frontend/build/CMakeFiles/PCSX2_ReWrite.dir/DependInfo.cmake --color=
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/PCSX2_ReWrite.dir/build.make CMakeFiles/PCSX2_ReWrite.dir/build
[ 99%] Linking CXX executable PCSX2_ReWrite.app/Contents/MacOS/PCSX2_ReWrite
/usr/local/Cellar/cmake/3.7.2/bin/cmake -E cmake_link_script CMakeFiles/PCSX2_ReWrite.dir/link.txt --verbose=1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -O3 -DNDEBUG -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.9 -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/PCSX2_ReWrite.dir/PCSX2_Frontend.cpp.o -o PCSX2_ReWrite.app/Contents/MacOS/PCSX2_ReWrite /Users/alawi/PCSX2_rewrite/PCSX2_Core/build/libPCSX2_Core.a
Undefined symbols for architecture x86_64:
"CDVDNvram_t::ILINK_DATA_MAGIC", referenced from:
``` it will then continue one with the exact same errors.
Yea looks like your right. Interesting how MSVC says nothing... I'll read up more about it during my lunch breaks.
There is quite a lot of those members, but looks like it just needs a definition without any initialiser which can stay in the header? Could possibly use a script to look through all the files and generate them anyway.
74 to be exact :p
from what I understood yes, but it can't go into the same class block, otherwise you'd get a redefinition error, so it can go to the bottom, or into the calling header(or source) file... it seems weird and a bit counter intuitive essentially redefining it everywhere else you want to use it.
Ok, I will spend time this week fixing up everything for clang/llvm as well as gcc (just tested, there were a few other errors).
Among other things I'll also take out the MSVC precompiled header stuff, doesn't need to be there.
Since you're trying to fix the project up, you should check '#define somevar', I know you've been using 1 and 0 for on and off (or so it seemed), but the minute you call define you'll trigger '#if defined(somevar)'.
It just means building as Release wasn't using the correct macros, it was a really quick look, so I could have missed how you're trying to use them and since I won't be able to have a more detailed look, I thought I'll mention it here til then. If it's as simple as it seemed, removing all '#define some 0' should fix it
I am only using the #if defined() for BUILD_DEBUG, the rest are being used as #if VAR.
ah, yes you're correct, just checked that.
I am in the process of fixing those issues, and that is working. However, I think I might have stumbled upon a clang bug. See if you can compile this file:
#include <memory>
#include <vector>
#include <cstdint>
#include <fstream>
#include <stdexcept>
struct test { static constexpr size_t sz = 0x10; };
class HwordMemory_t
{
public:
HwordMemory_t(const size_t byteSize) :
mMemoryByteSize(byteSize),
mMemory(mMemoryByteSize / 2, 0)
{
}
void dump(const char * fileStr)
{
std::ofstream file(fileStr, std::ios_base::binary);
if (file.fail()) throw std::runtime_error("dump() tried to open file, but it failed! Check file exists and has read permissions.");
file.write(reinterpret_cast<char*>(&mMemory[0]), mMemoryByteSize);
}
private:
size_t mMemoryByteSize;
std::vector<uint16_t> mMemory;
};
int main(int argc, char * argv[])
{
std::shared_ptr<HwordMemory_t> t = std::make_shared<HwordMemory_t>(test::sz);
t->dump("test.bin");
return 0;
}
Using windows subsystem for linux, I get a link error using clang, but GCC is ok.
Marco@localhost:/mnt/c/Shared/Dev/Temp/cppbug$ ls -l
total 2049
-rwxrwxrwx 1 root root 842 May 18 14:47 main.cpp
Marco@localhost:/mnt/c/Shared/Dev/Temp/cppbug$ clang++ -g -O3 -std=c++14 -o main main.cpp
/tmp/main-ede2b9.o: In function `void __gnu_cxx::new_allocator<HwordMemory_t>::construct<HwordMemory_t, unsigned long const&>(HwordMemory_t*, unsigned long const&)':
/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/ext/new_allocator.h:120: undefined reference to `test::sz'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Marco@localhost:/mnt/c/Shared/Dev/Temp/cppbug$ ls -l
total 2049
-rwxrwxrwx 1 root root 842 May 18 14:47 main.cpp
Marco@localhost/mnt/c/Shared/Dev/Temp/cppbug$ g++ -g -O3 -std=c++14 -o main main.cpp
Marco@localhost:/mnt/c/Shared/Dev/Temp/cppbug$ ls -l
total 49153
-rwxrwxrwx 1 root root 90184 May 18 14:49 main
-rwxrwxrwx 1 root root 842 May 18 14:47 main.cpp
Marco@localhost:/mnt/c/Shared/Dev/Temp/cppbug$ ./main
Marco@localhost:/mnt/c/Shared/Dev/Temp/cppbug$ ls -l
total 49162
-rwxrwxrwx 1 root root 90184 May 18 14:49 main
-rwxrwxrwx 1 root root 842 May 18 14:47 main.cpp
-rwxrwxrwx 1 root root 16 May 18 14:49 test.bin
Marco@localhost:/mnt/c/Shared/Dev/Temp/cppbug$
$ clang++ -std=c++14 test.cpp
Undefined symbols for architecture x86_64:
"test::sz", referenced from:
_main in test-1b5b02.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
same error, but this does seem like the previous error no? except In this case can't think of a way you can redefine sz
.
Yea that's what I mean... I think it's a Clang bug. GCC works fine with it.
I know why it's happening too - it tries to use a reference to the constant instead of just using it at compile time.
Ok... using -std=c++1z instead of c++14 in clang works. There is a bug somewhere.. either GCC or clang, but this works for now.
it might not be a 'bug', since this sounds like its more of a feature in cpp 17.
There is definitely something wrong with clang, version 3.8 doesnt work at all with the std=c++1z option, only 4.0+ do for me (haven't tried 3.9). I will treat it as a clang bug until they get back to me anyway. I've fixed all of the bugs on my side, so I'll close this issue now. If you want to compile under clang you have to use clang++-4.0 -std=c++1z
for now.
to report back on this, on Xcode 8.3 (AppleClang version is 8.1.0) the project can compile and run. while on my previous attempts, I was using Xcode 8.2.1 (AppleClang 8.0.0) it errored out as above.
AppleClang
is how cmake identifies the compiler.
Ok thats good news. Would adding a check:
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
if(${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 8.1.0)
message(FATAL_ERROR "apple clang version < 8.1.0 not supported")
endif()
endif()
work in CMake? I can add it but can't test it.
Also what -std=c++xx flag are you using? Does -std=c++14 work?
yes, that check is correct, as for the flag it had to be -std=c++1z
.
Hi there, You're project have been brought to my attention some few months ago, and I've been peeking about ever know and then, and it seems you're making good progress, so i thought it'll be interesting to see if this can be compiled on OSX.
but I've ran into linking issues, you'll probably quickly notice the pattern, all the undefined symbols are
static constexpr
, unfortunately my cpp is rather raw, so i wasnt sure about the best way to fix it, so I'll have to leave this with you.P.S, If you'd like, I've created a basic cmake script in order to compile this on OSX, so I'll send you a PR perhaps in a weeks time, once i get the chance to test it on different platforms for make sure for consistency.