Open humbertodias opened 6 months ago
something similar to this here
It appears that ppu-g++ 13.2.0 lacks support for std::thread. Consequently, I opted for the traditional C pthread approach as an alternative inside cpp code using extern "C".
Instead of
std::thread t1(threadFunction, 1);
use
pthread_create(&thread_id, nullptr, thread_function, nullptr);
[!NOTE]
pthread isn't supported natively as well on ps3. however, luckelly we have a ported version of it here pthread-emb-ps3.
docker run -i --rm hldtux/ps3dev bash -s <<EOF
echo '#include <iostream>
extern "C" {
#include <pthread.h>
}
void* thread_function(void* arg) {
std::cout << "Hello from thread\n";
return nullptr;
}
int main() {
pthread_t thread_id;
pthread_create(&thread_id, nullptr, thread_function, nullptr);
pthread_join(thread_id, nullptr);
std::cout << "Back in main thread\n";
return 0;
}' > main.cpp
ppu-g++ main.cpp -o main \
-I/usr/local/ps3dev/portlibs/ppu/include \
-L/usr/local/ps3dev/portlibs/ppu/lib -lpthread
ppu-g++ --version
file main
EOF
output
ppu-g++ (GCC) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
main: ELF 64-bit MSB executable, 64-bit PowerPC or cisco 7500, Power ELF V1 ABI, version 1 (SYSV), statically linked, with debug_info, not strippe
d
Is there anything missing on ppu-g++ to compile std::thread ?
Trying to compile std::thread
output