Problem with the compilation
Hi,
I did everything you mentioned about the installation of the python-ios-template. However, once I click on the xcodeproj file, and want to build I got some errors that I'm not able to solve. I just show you some errors I have :
error: implicit declaration of function '_Py_char2wchar' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
wpython_home = _Py_char2wchar([python_home UTF8String], NULL);
error: implicit declaration of function '_Py_char2wchar' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
python_argv[0] = _Py_char2wchar(main_script, NULL);
Undefined symbols for architecture x86_64:
"_BZ2_bzCompress", referenced from:
_compress in Python(_bz2module.o)
"_BZ2_bzCompressEnd", referenced from:
_BZ2Compressor_dealloc in Python(_bz2module.o)
"_BZ2_bzCompressInit", referenced from:
__bz2_BZ2Compressor___init__ in Python(_bz2module.o)
"_BZ2_bzDecompress", referenced from:
__bz2_BZ2Decompressor_decompress in Python(_bz2module.o)
"_BZ2_bzDecompressEnd", referenced from:
_BZ2Decompressor_dealloc in Python(_bz2module.o)
"_BZ2_bzDecompressInit", referenced from:
__bz2_BZ2Decompressor___init__ in Python(_bz2module.o)
"_lzma_alone_decoder", referenced from:
__lzma_LZMADecompressor___init__ in Python(_lzmamodule.o)
"_lzma_alone_encoder", referenced from:
_Compressor_init in Python(_lzmamodule.o)
"_lzma_auto_decoder", referenced from:
__lzma_LZMADecompressor___init__ in Python(_lzmamodule.o)
"_lzma_check_is_supported", referenced from:
__lzma_is_check_supported in Python(_lzmamodule.o)
"_lzma_code", referenced from:
_compress in Python(_lzmamodule.o)
__lzma_LZMADecompressor_decompress in Python(_lzmamodule.o)
"_lzma_easy_encoder", referenced from:
_Compressor_init in Python(_lzmamodule.o)
"_lzma_end", referenced from:
_Compressor_dealloc in Python(_lzmamodule.o)
_Decompressor_dealloc in Python(_lzmamodule.o)
"_lzma_get_check", referenced from:
__lzma_LZMADecompressor_decompress in Python(_lzmamodule.o)
"_lzma_lzma_preset", referenced from:
_lzma_filter_converter in Python(_lzmamodule.o)
_Compressor_init in Python(_lzmamodule.o)
"_lzma_properties_decode", referenced from:
__lzma__decode_filter_properties in Python(_lzmamodule.o)
"_lzma_properties_encode", referenced from:
__lzma__encode_filter_properties in Python(_lzmamodule.o)
"_lzma_properties_size", referenced from:
__lzma__encode_filter_properties in Python(_lzmamodule.o)
"_lzma_raw_decoder", referenced from:
__lzma_LZMADecompressor___init__ in Python(_lzmamodule.o)
"_lzma_raw_encoder", referenced from:
_Compressor_init in Python(_lzmamodule.o)
"_lzma_stream_decoder", referenced from:
__lzma_LZMADecompressor___init__ in Python(_lzmamodule.o)
"_lzma_stream_encoder", referenced from:
_Compressor_init in Python(_lzmamodule.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have Python 2.7.12 and Python 3.5. I tried with both and got the same things. I precise that I have added all the framework inside the directory.
Could you please help me ?
Thank, Regards
Can you confirm that when you used the template, you used the correct branch of this project for the version of Python you were using? The master branch (until very recently) was only compatible with Python 3.4; there have been significant API changes in CPython between 2.7, 3.4 and 3.5.
Can I get you to retry with the 2.7 or 3.5 branch (for the corresponding version of Python)?
My bad, I had well the corresponding file but I didn't do the correct cookiecutter command line. I had forgotten the "--checkout 2.7" part
cookiecutter https://github.com/pybee/Python-iOS-template --checkout 2.7
So far so good, it's now compiling without problems. However the app crash when I run it. I got this message error :
Application/5FF173EE-3D3F-4D21-B7AA-EA36BB51F108/python_recog.app/Library/Python.framework/Resources
2016-07-12 11:12:26.453 python_recog[55153:6199073] Initializing Python runtime
2016-07-12 11:12:26.732 python_recog[55153:6199073] Unable to locate python_recog app module file
the name of my app and directory is "python_recog"
Do you have any idea ?
Thank you again :)
Looks like there's a problem finding the Python entry point. What does the directory structure under the "app" folder of the template look like? The template is expecting to find:
app/
python_recog/
__init__.py
app.py
and it's the app.py that will be executed at startup. If app.py doesn't exist in that location, you'll get the error you've described.
If you want to use a different entry point, you can modify main.m and provide a different path.
Okey thank you ! Problem solved. I changed the path ! Now If I understand well I have to use rubicon-obj to create a Python Delegate right ? (Because now it crashed because It's not able to instantiate it)
Thank
Correct - you need to create a subclass of NSObject called PythonAppDelegate - but that class can be native ObjC, or Python - it's up to you.
@freakboy3742 I believe this can be closed.