zoglauer / megalib

MEGAlib - the Medium-Energy Gamma-ray Astronomy library
http://megalibtoolkit.com
Other
41 stars 32 forks source link

src/MLMLOSEM.cxx:91:2: error: use of undeclared identifier 'random_shuffle' #68

Closed DAMPELB closed 1 year ago

DAMPELB commented 2 years ago

I try to install Megalib, but at the process of compiling, I face this problem:

src/MLMLOSEM.cxx:91:2: error: use of undeclared identifier 'random_shuffle' random_shuffle(m_Storage.begin(), m_Storage.end());

From the internet, they told me "random_shuffle" was not supported by C11 and C17 What should I do.

Thanks.

zoglauer commented 2 years ago

Hello,

Can you let me know which OS and which MEGAlib branch you are using? This is usually working.

Best, Andreas

On 11/18/21 8:40 AM, Libo wrote:

I try to install Megalib, but at the process of compiling, I face this problem:

src/MLMLOSEM.cxx:91:2: error: use of undeclared identifier 'random_shuffle' random_shuffle(m_Storage.begin(), m_Storage.end());

From the internet, they told me "random_shuffle" was not supported by C11 and C17 What should I do.

Thanks.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/zoglauer/megalib/issues/68, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBIYWDPU7SHQLDA5BGISTTUMUUAJANCNFSM5IKCHVIA.

DAMPELB commented 2 years ago

Hello, Can you let me know which OS and which MEGAlib branch you are using? This is usually working. Best, Andreas On 11/18/21 8:40 AM, Libo wrote: I try to install Megalib, but at the process of compiling, I face this problem: src/MLMLOSEM.cxx:91:2: error: use of undeclared identifier 'random_shuffle' random_shuffle(m_Storage.begin(), m_Storage.end()); From the internet, they told me "random_shuffle" was not supported by C11 and C17 What should I do. Thanks. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#68>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBIYWDPU7SHQLDA5BGISTTUMUUAJANCNFSM5IKCHVIA.

Thanks for your reply, The system is macOS Monterey(12.0.1), and the version of MEGAlib is MEGAlib_v4-alpha. Now, I change the code of MLMLOSEM.cxx, you can see below, I change the function of random_shuffle() to shuffle() which is supported by Xcode13.1 and CLT 13. And then it can be compiled and successfully installed. But actually, I don't know the influence after changing the function. Thanks.

void MLMLOSEM::Shuffle() { //random_shuffle(m_Storage.begin(), m_Storage.end());

random_device rd;
mt19937 g(rd());
shuffle(m_Storage.begin(), m_Storage.end(), g);

}

zoglauer commented 2 years ago

Thanks. I fixed it in MEGAlib_v4-alpha. Can you check?

DAMPELB commented 2 years ago

Yes, I have checked, It can be install successfully on my laptop. Thanks.

But I also face another Problem. When I install MEGAlib(same version with above) on other computer(MacMini with M1 chip and same system version with above), It shows the problem below:

ld: file not found: @rpath/libgcc_s.1.1.dylib for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

But I have install gcc11 on MacMini by "brew install gcc", and I have checked the lib of "libgcc_s.1.1.dylib" is there. I don't know why they can not find the lib.... Looking forward your answer.

Thanks very much.