OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Can't find -lpython311 when compilling C++ file

  • Thread starter Thread starter LEBG
  • Start date Start date
L

LEBG

Guest
Im trying to use Python in C++ but when I try running with the button on vscode nothing happens. Full code:

Code:
#define PY_SSIZE_T_CLEAN
#include <python3.11\Python.h>



int main(int argc, char **argv){
    Py_Initialize();
    PyRun_SimpleString("print('Hello C++ from Python')");
    Py_Finalize();
    return 0;
}

I then tried to run using the terminal by using: g++ RunFile.cpp -o output -L C:\Python311\libs -lpython311 -I C:\Python311\include

but this error occurs : cannot find -lpython311: No such file or directory collect2.exe: error: ld returned 1 exit status

I then tried switching -lpython311 with -lpython3 but this occurs: undefined reference to PyRun_SimpleStringFlags'`

I tried chaging python311 to python3 but the PyRun_SimpleStringFlags didn't work

I use Windows 11 and python 11

I am a beginner.

Thank you for your time.
<p>Im trying to use Python in C++ but when I try running with the button on vscode nothing happens.
Full code:</p>
<pre><code>#define PY_SSIZE_T_CLEAN
#include <python3.11\Python.h>



int main(int argc, char **argv){
Py_Initialize();
PyRun_SimpleString("print('Hello C++ from Python')");
Py_Finalize();
return 0;
}
</code></pre>
<p>I then tried to run using the terminal by using:
<code>g++ RunFile.cpp -o output -L C:\Python311\libs -lpython311 -I C:\Python311\include</code></p>
<p>but this error occurs :
<code>cannot find -lpython311: No such file or directory collect2.exe: error: ld returned 1 exit status</code></p>
<p>I then tried switching -lpython311 with -lpython3 but this occurs:
<code>undefined reference to </code>PyRun_SimpleStringFlags'`</p>
<p>I tried chaging python311 to python3 but the <code>PyRun_SimpleStringFlags</code> didn't work</p>
<p>I use Windows 11 and python 11</p>
<p>I am a beginner.</p>
<p>Thank you for your time.</p>
 

Latest posts

Top