marcosatti / orbum

PS2 Emulator - Archived
65 stars 5 forks source link

OSX Compile Error #1

Closed Zer0xFF closed 7 years ago

Zer0xFF commented 7 years ago

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.

Undefined symbols for architecture x86_64:
  "CDVDNvram_t::ILINK_DATA_MAGIC", referenced from:
      CDVD_s::initialise() in libPCSX2_Core.a(CDVD_s.cpp.o)
  "VIFcodeTable::VIFCODE_BASE_TABLE", referenced from:
      VIFcodeTable::getInfo(VIFcodeInstruction_t const*) in libPCSX2_Core.a(VIFcodeInstructionTable.cpp.o)
  "VIFcodeTable::VIFCODE_UNPACK_TABLE", referenced from:
      VIFcodeTable::getInfo(VIFcodeInstruction_t const*) in libPCSX2_Core.a(VIFcodeInstructionTable.cpp.o)
  "SPU2CoreTable::SPU2_CORE_TABLE", referenced from:
      SPU2CoreTable::getInfo(SPU2Core_t const*) in libPCSX2_Core.a(SPU2CoreTable.cpp.o)
  "EEDmacChannelTable::EEDMAC_CHANNEL_TABLE", referenced from:
      EEDmacChannelTable::getInfo(EEDmacChannel_t const*) in libPCSX2_Core.a(EEDmacChannelTable.cpp.o)
  "EEDmacChannelTable::STD_MAP", referenced from:
      EEDmacChannelTable::getSTDChannelIndex(int) in libPCSX2_Core.a(EEDmacChannelTable.cpp.o)
  "EEDmacChannelTable::STS_MAP", referenced from:
      EEDmacChannelTable::getSTSChannelIndex(int) in libPCSX2_Core.a(EEDmacChannelTable.cpp.o)
  "IOPDmacChannelTable::IOPDMAC_CHANNEL_TABLE", referenced from:
      IOPDmacChannelTable::getInfo(IOPDmacChannel_t const*) in libPCSX2_Core.a(IOPDmacChannelTable.cpp.o)
  "VUCoreRegister_MAC_t::Fields::W_FLAGS", referenced from:
      l__ZZN20VUCoreRegister_MAC_t16clearVectorFieldE8System_tiE11FIELD_FLAGS in libPCSX2_Core.a(VUCoreRegisters_t.cpp.o)
  "VUCoreRegister_MAC_t::Fields::X_FLAGS", referenced from:
      l__ZZN20VUCoreRegister_MAC_t16clearVectorFieldE8System_tiE11FIELD_FLAGS in libPCSX2_Core.a(VUCoreRegisters_t.cpp.o)
  "VUCoreRegister_MAC_t::Fields::Y_FLAGS", referenced from:
      l__ZZN20VUCoreRegister_MAC_t16clearVectorFieldE8System_tiE11FIELD_FLAGS in libPCSX2_Core.a(VUCoreRegisters_t.cpp.o)
  "VUCoreRegister_MAC_t::Fields::Z_FLAGS", referenced from:
      l__ZZN20VUCoreRegister_MAC_t16clearVectorFieldE8System_tiE11FIELD_FLAGS in libPCSX2_Core.a(VUCoreRegisters_t.cpp.o)
  "EECoreExceptionsTable::EECORE_EXCEPTION_TABLE", referenced from:
      EECoreExceptionsTable::getInfo(EECoreException_t) in libPCSX2_Core.a(EECoreExceptionsTable.cpp.o)
  "EEDmacRegister_STAT_t::Fields::CHANNEL_IRQ_KEYS", referenced from:
      EEDmac_s::transferNormal() in libPCSX2_Core.a(EEDmac_s.cpp.o)
      EEDmac_s::transferChain() in libPCSX2_Core.a(EEDmac_s.cpp.o)
      EEDmac_s::setStateSuspended() const in libPCSX2_Core.a(EEDmac_s.cpp.o)
  "EEIntcRegister_STAT_t::Fields::TIM_KEYS", referenced from:
      EETimers_s::handleTimerInterrupt() const in libPCSX2_Core.a(EETimers_s.cpp.o)
  "IOPTimersTimer_TIM0_t::TIMER_ID", referenced from:
      IOPTimersTimer_TIM0_t::IOPTimersTimer_TIM0_t() in libPCSX2_Core.a(IOPTimersTimers_t.cpp.o)
  "IOPTimersTimer_TIM1_t::TIMER_ID", referenced from:
      IOPTimersTimer_TIM1_t::IOPTimersTimer_TIM1_t() in libPCSX2_Core.a(IOPTimersTimers_t.cpp.o)
  "IOPTimersTimer_TIM2_t::TIMER_ID", referenced from:
      IOPTimersTimer_TIM2_t::IOPTimersTimer_TIM2_t() in libPCSX2_Core.a(IOPTimersTimers_t.cpp.o)
  "IOPTimersTimer_TIM3_t::TIMER_ID", referenced from:
      IOPTimersTimer_TIM3_t::IOPTimersTimer_TIM3_t() in libPCSX2_Core.a(IOPTimersTimers_t.cpp.o)
  "IOPTimersTimer_TIM4_t::TIMER_ID", referenced from:
      IOPTimersTimer_TIM4_t::IOPTimersTimer_TIM4_t() in libPCSX2_Core.a(IOPTimersTimers_t.cpp.o)
  "IOPTimersTimer_TIM5_t::TIMER_ID", referenced from:
      IOPTimersTimer_TIM5_t::IOPTimersTimer_TIM5_t() in libPCSX2_Core.a(IOPTimersTimers_t.cpp.o)
  "EECoreInstructionTable::EECORE_S_TABLE", referenced from:
      EECoreInstructionTable::EECORE_INSTRUCTION_S_LOOKUP(EECoreInstruction_t const*) in libPCSX2_Core.a(EECoreInstructionTable.cpp.o)
  "EECoreInstructionTable::EECORE_W_TABLE", referenced from:
      EECoreInstructionTable::EECORE_INSTRUCTION_W_LOOKUP(EECoreInstruction_t const*) in libPCSX2_Core.a(EECoreInstructionTable.cpp.o)
  "EECoreInstructionTable::EECORE_C0_TABLE", referenced from:
      EECoreInstructionTable::EECORE_INSTRUCTION_C0_LOOKUP(EECoreInstruction_t const*) in libPCSX2_Core.a(EECoreInstructionTable.cpp.o)
  "EECoreInstructionTable::EECORE_BC0_TABLE", referenced from:
      EECoreInstructionTable::EECORE_INSTRUCTION_BC0_LOOKUP(EECoreInstruction_t const*) in libPCSX2_Core.a(EECoreInstructionTable.cpp.o)
  "EECoreInstructionTable::EECORE_BC1_TABLE", referenced from:
      EECoreInstructionTable::EECORE_INSTRUCTION_BC1_LOOKUP(EECoreInstruction_t const*) in libPCSX2_Core.a(EECoreInstructionTable.cpp.o)
  "EECoreInstructionTable::EECORE_BC2_TABLE", referenced from:
      EECoreInstructionTable::EECORE_INSTRUCTION_BC2_LOOKUP(EECoreInstruction_t const*) in libPCSX2_Core.a(EECoreInstructionTable.cpp.o)
  "EECoreInstructionTable::EECORE_CO0_TABLE", referenced from:
      EECoreInstructionTable::EECORE_INSTRUCTION_CO0_LOOKUP(EECoreInstruction_t const*) in libPCSX2_Core.a(EECoreInstructionTable.cpp.o)
  "EECoreInstructionTable::EECORE_CO1_TABLE", referenced from:
      EECoreInstructionTable::EECORE_INSTRUCTION_CO1_LOOKUP(EECoreInstruction_t const*) in libPCSX2_Core.a(EECoreInstructionTable.cpp.o)
  "EECoreInstructionTable::EECORE_MMI_TABLE", referenced from:
      EECoreInstructionTable::EECORE_INSTRUCTION_MMI_LOOKUP(EECoreInstruction_t const*) in libPCSX2_Core.a(EECoreInstructionTable.cpp.o)
  "EECoreInstructionTable::EECORE_COP0_TABLE", referenced from:
      EECoreInstructionTable::EECORE_INSTRUCTION_COP0_LOOKUP(EECoreInstruction_t const*) in libPCSX2_Core.a(EECoreInstructionTable.cpp.o)
  "EECoreInstructionTable::EECORE_COP1_TABLE", referenced from:
      EECoreInstructionTable::EECORE_INSTRUCTION_COP1_LOOKUP(EECoreInstruction_t const*) in libPCSX2_Core.a(EECoreInstructionTable.cpp.o)
  "EECoreInstructionTable::EECORE_COP2_TABLE", referenced from:
      EECoreInstructionTable::EECORE_INSTRUCTION_COP2_LOOKUP(EECoreInstruction_t const*) in libPCSX2_Core.a(EECoreInstructionTable.cpp.o)
  "EECoreInstructionTable::EECORE_MMI0_TABLE", referenced from:
      EECoreInstructionTable::EECORE_INSTRUCTION_MMI0_LOOKUP(EECoreInstruction_t const*) in libPCSX2_Core.a(EECoreInstructionTable.cpp.o)
  "EECoreInstructionTable::EECORE_MMI1_TABLE", referenced from:
      EECoreInstructionTable::EECORE_INSTRUCTION_MMI1_LOOKUP(EECoreInstruction_t const*) in libPCSX2_Core.a(EECoreInstructionTable.cpp.o)
  "EECoreInstructionTable::EECORE_MMI2_TABLE", referenced from:
      EECoreInstructionTable::EECORE_INSTRUCTION_MMI2_LOOKUP(EECoreInstruction_t const*) in libPCSX2_Core.a(EECoreInstructionTable.cpp.o)
  "EECoreInstructionTable::EECORE_MMI3_TABLE", referenced from:
      EECoreInstructionTable::EECORE_INSTRUCTION_MMI3_LOOKUP(EECoreInstruction_t const*) in libPCSX2_Core.a(EECoreInstructionTable.cpp.o)
  "EECoreInstructionTable::EECORE_VEXT0_TABLE", referenced from:
      EECoreInstructionTable::EECORE_INSTRUCTION_VEXT0_LOOKUP(EECoreInstruction_t const*) in libPCSX2_Core.a(EECoreInstructionTable.cpp.o)
  "EECoreInstructionTable::EECORE_VEXT1_TABLE", referenced from:
      EECoreInstructionTable::EECORE_INSTRUCTION_VEXT1_LOOKUP(EECoreInstruction_t const*) in libPCSX2_Core.a(EECoreInstructionTable.cpp.o)
  "EECoreInstructionTable::EECORE_VEXT2_TABLE", referenced from:
      EECoreInstructionTable::EECORE_INSTRUCTION_VEXT2_LOOKUP(EECoreInstruction_t const*) in libPCSX2_Core.a(EECoreInstructionTable.cpp.o)
  "EECoreInstructionTable::EECORE_VEXT3_TABLE", referenced from:
      EECoreInstructionTable::EECORE_INSTRUCTION_VEXT3_LOOKUP(EECoreInstruction_t const*) in libPCSX2_Core.a(EECoreInstructionTable.cpp.o)
  "EECoreInstructionTable::EECORE_OPCODE_TABLE", referenced from:
      EECoreInstructionTable::EECORE_INSTRUCTION_OPCODE_LOOKUP(EECoreInstruction_t const*) in libPCSX2_Core.a(EECoreInstructionTable.cpp.o)
  "EECoreInstructionTable::EECORE_REGIMM_TABLE", referenced from:
      EECoreInstructionTable::EECORE_INSTRUCTION_REGIMM_LOOKUP(EECoreInstruction_t const*) in libPCSX2_Core.a(EECoreInstructionTable.cpp.o)
  "EECoreInstructionTable::EECORE_SPECIAL_TABLE", referenced from:
      EECoreInstructionTable::EECORE_INSTRUCTION_SPECIAL_LOOKUP(EECoreInstruction_t const*) in libPCSX2_Core.a(EECoreInstructionTable.cpp.o)
  "IOPCoreExceptionsTable::IOPCORE_EXCEPTION_TABLE", referenced from:
      IOPCoreExceptionsTable::getInfo(IOPCoreException_t) in libPCSX2_Core.a(IOPCoreExceptionsTable.cpp.o)
  "IOPDmacRegister_ICR0_t::Fields::CHANNEL_TCI_KEYS", referenced from:
      IOPDmac_s::setStateSuspended() const in libPCSX2_Core.a(IOPDmac_s.cpp.o)
  "IOPDmacRegister_ICR1_t::Fields::CHANNEL_IQE_KEYS", referenced from:
      IOPDmac_s::transferChain() in libPCSX2_Core.a(IOPDmac_s.cpp.o)
      IOPDmac_s::isChannelIRQEnabled() const in libPCSX2_Core.a(IOPDmac_s.cpp.o)
  "IOPDmacRegister_ICR1_t::Fields::CHANNEL_TCI_KEYS", referenced from:
      IOPDmac_s::setStateSuspended() const in libPCSX2_Core.a(IOPDmac_s.cpp.o)
  "IOPDmacRegister_PCR0_t::Fields::CHANNEL_ENABLE_KEYS", referenced from:
      IOPDmac_s::isChannelEnabled() const in libPCSX2_Core.a(IOPDmac_s.cpp.o)
  "IOPDmacRegister_PCR1_t::Fields::CHANNEL_ENABLE_KEYS", referenced from:
      IOPDmac_s::isChannelEnabled() const in libPCSX2_Core.a(IOPDmac_s.cpp.o)
  "IOPIntcRegister_STAT_t::Fields::TMR_KEYS", referenced from:
      IOPTimers_s::handleTimerInterrupt() const in libPCSX2_Core.a(IOPTimers_s.cpp.o)
  "IOPCoreInstructionTable::IOPCORE_COP0_TABLE", referenced from:
      IOPCoreInstructionTable::IOPCORE_INSTRUCTION_COP0_LOOKUP(IOPCoreInstruction_t const*) in libPCSX2_Core.a(IOPCoreInstructionTable.cpp.o)
  "IOPCoreInstructionTable::IOPCORE_COP2_TABLE", referenced from:
      IOPCoreInstructionTable::IOPCORE_INSTRUCTION_COP2_LOOKUP(IOPCoreInstruction_t const*) in libPCSX2_Core.a(IOPCoreInstructionTable.cpp.o)
  "IOPCoreInstructionTable::IOPCORE_CP2BSC_TABLE", referenced from:
      IOPCoreInstructionTable::IOPCORE_INSTRUCTION_CP2BSC_LOOKUP(IOPCoreInstruction_t const*) in libPCSX2_Core.a(IOPCoreInstructionTable.cpp.o)
  "IOPCoreInstructionTable::IOPCORE_OPCODE_TABLE", referenced from:
      IOPCoreInstructionTable::IOPCORE_INSTRUCTION_OPCODE_LOOKUP(IOPCoreInstruction_t const*) in libPCSX2_Core.a(IOPCoreInstructionTable.cpp.o)
  "IOPCoreInstructionTable::IOPCORE_REGIMM_TABLE", referenced from:
      IOPCoreInstructionTable::IOPCORE_INSTRUCTION_REGIMM_LOOKUP(IOPCoreInstruction_t const*) in libPCSX2_Core.a(IOPCoreInstructionTable.cpp.o)
  "IOPCoreInstructionTable::IOPCORE_SPECIAL_TABLE", referenced from:
      IOPCoreInstructionTable::IOPCORE_INSTRUCTION_SPECIAL_LOOKUP(IOPCoreInstruction_t const*) in libPCSX2_Core.a(IOPCoreInstructionTable.cpp.o)
  "SPU2Register_SPDIF_IRQINFO_t::Fields::IRQ_KEYS", referenced from:
      SPU2_s::readHwordMemory(unsigned int) const in libPCSX2_Core.a(SPU2_s.cpp.o)
      SPU2_s::writeHwordMemory(unsigned int, unsigned short) const in libPCSX2_Core.a(SPU2_s.cpp.o)
  "Common_t::DEBUG_FIFO_SIZE", referenced from:
      Common_t::Common_t() in libPCSX2_Core.a(Common_t.cpp.o)
  "Constants::EE::MainMemory::SIZE_MAIN_MEMORY", referenced from:
      EE_t::EE_t() in libPCSX2_Core.a(EE_t.cpp.o)
  "Constants::EE::ROM::SIZE_BOOT_ROM", referenced from:
      EE_t::EE_t() in libPCSX2_Core.a(EE_t.cpp.o)
  "Constants::EE::ROM::SIZE_EROM", referenced from:
      EE_t::EE_t() in libPCSX2_Core.a(EE_t.cpp.o)
  "Constants::EE::ROM::SIZE_ROM1", referenced from:
      EE_t::EE_t() in libPCSX2_Core.a(EE_t.cpp.o)
  "Constants::EE::ROM::SIZE_ROM2", referenced from:
      EE_t::EE_t() in libPCSX2_Core.a(EE_t.cpp.o)
  "Constants::EE::EECore::ScratchpadMemory::SIZE_SCRATCHPAD_MEMORY", referenced from:
      EECore_t::EECore_t() in libPCSX2_Core.a(EECore_t.cpp.o)
  "Constants::IOP::ParallelPort::SIZE_PARALLEL_PORT", referenced from:
      IOP_t::IOP_t() in libPCSX2_Core.a(IOP_t.cpp.o)
  "Constants::IOP::IOPCore::ScratchpadMemory::SIZE_SCRATCHPAD_MEMORY", referenced from:
      IOPCore_t::IOPCore_t() in libPCSX2_Core.a(IOPCore_t.cpp.o)
  "Constants::IOP::IOPMemory::SIZE_IOP_MEMORY", referenced from:
      IOP_t::IOP_t() in libPCSX2_Core.a(IOP_t.cpp.o)
  "Constants::CDVD::SIZE_NVRAM", referenced from:
      CDVDNvram_000_t::CDVDNvram_000_t(char const*, bool, bool) in libPCSX2_Core.a(CDVDNvrams_t.cpp.o)
  "Constants::SPU2::SIZE_MAIN_MEMORY", referenced from:
      SPU2_t::SPU2_t() in libPCSX2_Core.a(SPU2_t.cpp.o)
  "Constants::SIZE_4KB", referenced from:
      VUCore_VU0_t::VUCore_VU0_t(std::__1::shared_ptr<EECoreCOP0_t> const&) in libPCSX2_Core.a(VUCores_t.cpp.o)
  "Constants::SIZE_16KB", referenced from:
      VUCore_VU1_t::VUCore_VU1_t() in libPCSX2_Core.a(VUCores_t.cpp.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
marcosatti commented 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.

Zer0xFF commented 7 years ago

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.
marcosatti commented 7 years ago

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.

Zer0xFF commented 7 years ago

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.

marcosatti commented 7 years ago

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.

Zer0xFF commented 7 years ago

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

marcosatti commented 7 years ago

I am only using the #if defined() for BUILD_DEBUG, the rest are being used as #if VAR.

Zer0xFF commented 7 years ago

ah, yes you're correct, just checked that.

marcosatti commented 7 years ago

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$
Zer0xFF commented 7 years ago
$ 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.

marcosatti commented 7 years ago

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.

marcosatti commented 7 years ago

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.

Zer0xFF commented 7 years ago

it might not be a 'bug', since this sounds like its more of a feature in cpp 17.

marcosatti commented 7 years ago

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.

Zer0xFF commented 7 years ago

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.

marcosatti commented 7 years ago

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?

Zer0xFF commented 7 years ago

yes, that check is correct, as for the flag it had to be -std=c++1z.