iOS Build Environment Help Center

il2cpp source

append delete Trix

Windows version: 10
iOS builder : latest

Hello, I know this question has no point to be there but I saw that it was possible instead of using libil2cpp.a static prebuild library provided in Xcode project we can use the il2cpp source in Unity editor files to port some modification to it like for metadata and use it in android we can directly change files and build apk and done we use our modified version of il2cpp for iOS there is a prebuild static library ( libil2cpp.a ) i would like to know if it would be possible with your builder instead of using the prebuild if we could use the source and you compile it before building Unity framework / the app or make a new static library with our modified versions. Thanks in advance for any reply.

Reply RSS

Replies

append delete #1. Pierre-Marie Baty

Hello

Please put punctuation signs in your message. I don’t understand what you say in the way it is written. Thank you in advance.

append delete #2. Trix

Hi, sorry for the last message.

My question in specific way is that, instead of using the prebuild static library ( libil2cpp.a ) can we use the libil2cpp source ? Because I’ve made modification to it for metadata in all plateforms else than iOS it’s fine because there is no prebuild but for iOS they use a prebuild il2cpp compile source as mentioned above.

append delete #3. Pierre-Marie Baty

Where is this source located ?

Do you have some information on how Unity builds this static library ? (compiler flags, preprocessor definitions, etc.)

append delete #4. Trix

Source location : C:\Program Files\Unity\Hub\Editor\Unity Version\Editor\Data\il2cpp\libil2cpp\

Unfortunately I don’t have any other informations.

Mainly edited the source to change how the metadata file is loaded to support my encrypted metadata ( to avoid stealing , cheating etc..) and, it works perfectly in all plateforms now trying to use it on iOS but I need to get rid of the prebuild static library.

Thanks in advance for the help and I’m sure that the prebuild is that source because if we look in the generated Xcode project Libraries\libil2cpp\include\ there is all headers of that source in the location given.

append delete #5. Pierre-Marie Baty

That's interesting. I didn't know they provided the source of that library.

In theory, sure, it can be recompiled. However as it's very specific, and it has no project files, I don't think I'll provide that possibility directly in the builder UI. Rather, as all specific projects that require a tailor-made build pipeline, it would require a custom build script that would invoke the compiler from the command line to compile each file, then a final call to the archiver (ar.exe) to merge the object files together and produce the static library.

I see that the iOS code is merged with the OSX code in the source. In theory setting LIBIL2CPP_TARGET_IOS might be enough to do the job.

Do you need help with invoking the compiler with the right flags to compile these files for iOS or are you experienced enough in that ?

append delete #6. Trix

Hi, first thanks for not skipping this question unfortunately in the official unity forum nobody want to give help on that which i don’t understand why.

And yes if your free I would like some help with this. Have a nice day.

append delete #7. Pierre-Marie Baty

Are you at least somewhat experienced in calling compilers from the command line or not at all ? I'm afraid it'll be difficult for you if you never did.

To learn how to invoke the iOS compiler from the command line you can build one of your iOS Xcode projects in verbose mode : hold down the SHIFT key while you click the Build button in the builder UI. This will generate a very extensive build.log file in the Xcode project directory. You can then search that log file with a text editor for instances of calls to clang.exe (the compiler) and you'll see how it's called : with particular command-line flags, some of which are "response files", i.e. files that contain other flags. Select the ones you need for each of the source files you want to build, adjust the paths as needed, add -DLIBIL2CPP_TARGET_IOS=1 to the compiler flags, specify the missing include paths... the usual business.

Once you have all your source files compiled to object files, it'll be time to pack them in a single library, but right now try to achieve that milestone already.

append delete #8. Trix

Hello,

So I checked the build.log and saw I can use build.cmd with many parameter offered by you. So what I did so far for now is calling the build.cmd with builddir parameter that contain path to the il2cpp source and also with -cppflags that contain the compiler flag you told me to add.

But I’m having a problem where I didn’t found how to build without provisioning profile i checked build.log to know how my actual projects I’ve builded has been compiled without provisioning profile but haven’t found anything.

Thanks in advance.

append delete #9. Pierre-Marie Baty

The build.cmd options are documented with build -? or at the top of the file itself when you open it with a text editor. But that won't lead you anywhere. Build.cmd is for building projects. Here you have just a bunch of source files with nothing to tie them together. Don't call build.cmd just like that on the source directory. You should instead call the compiler clang.exe to compile each of these source files, with the appropriate flags. Start with just one source file so as to figure out the necessary flags for it to compile to an object file, and once you achieved that move on to the others.

#10. Trix

This post was deleted by its owner

#11. Trix

This post was deleted by its owner

#12. Trix

This post was deleted by its owner

append delete #13. Trix

after added all missing paths for headers i'm getting source errors :

commande line :
C:\iOS\builder\Toolchain>clang.exe -target arm64-apple-ios12.0 --sysroot "C:\Users\iosav\iOS Project Builder for Unity\SDK" -I "C:\Users\iosav\Documents\libil2cpp" -I "C:\Users\iosav\Documents\external\baselib\Include" -I "C:\Users\iosav\Documents\external\baselib\Platforms\OSX\Include" -I "C:\Users\iosav\Documents\external\google\sparsehash" -c "C:\Users\iosav\Documents\libil2cpp\il2cpp-mono-api.cpp" -o test.o

Clang output :
In file included from C:\Users\iosav\Documents\libil2cpp\il2cpp-mono-api.cpp:17:
In file included from C:\Users\iosav\Documents\libil2cpp/vm/Class.h:11:
C:\Users\iosav\Documents\libil2cpp\il2cpp-object-internals.h:358:14: error: reference to 'ReentrantLock' is ambiguous
baselib::ReentrantLock* synch_cs;
^
C:\Users\iosav\Documents\external\baselib\Include\Cpp/ReentrantLock.h:21:15: note: candidate found by name lookup is
'baselib::ReentrantLock'
class ReentrantLock
^
C:\Users\iosav\Documents\libil2cpp\il2cpp-object-internals.h:44:11: note: candidate found by name lookup is
'baselib::il2cpp_baselib::ReentrantLock'
class ReentrantLock;
^
1 error generated.

C:\iOS\builder\Toolchain>

append delete #14. Pierre-Marie Baty

That’s probably because you’re mixing the library’s public and private API header files. The public headers are meant to be used by projects that will use the compiled library, whereas the private ones are those that need to be used to build it. You have to decide which are which, keeping the private ones in the include paths and leaving the public ones aside.

append delete #15. Trix

Sorry, I don’t really see what you mean the path I’ve included with -I flag are the one in need to don’t get error file not found baselib and sparsehash is also in Unity editor files.

append delete #16. Pierre-Marie Baty

Swap these :

%
-I "C:\Users\iosav\Documents\external\baselib\Include"
-I "C:\Users\iosav\Documents\external\baselib\Platforms\OSX\Include"
%

The first one looks like the public API headers path. The second one looks like the private one. Since you're compiling the library, and not a program that uses the library, it's logical to include the private API headers before the public ones.

append delete #17. Trix

Hi, this didn’t changed anything still getting the same compile errors.

Thanks in advance for any replies.

append delete #18. Trix

compiled, made some changes to the source thanks for the help.

append delete #19. Trix

I think editing source was not a great idea, once I compiled all source files I’ve made them into a single object that is libil2cpp.a but the size is only 10 Mb which is isn’t normal because original one is around 69 and while building now getting a tons of error.

But without editing source even with swapping like you told I still get same compile error that is:

Clang output :
In file included from C:\Users\iosav\Documents\libil2cpp\il2cpp-mono-api.cpp:17:
In file included from C:\Users\iosav\Documents\libil2cpp/vm/Class.h:11:
C:\Users\iosav\Documents\libil2cpp\il2cpp-object-internals.h:358:14: error: reference to 'ReentrantLock' is ambiguous
baselib::ReentrantLock* synch_cs;
^
C:\Users\iosav\Documents\external\baselib\Include\Cpp/ReentrantLock.h:21:15: note: candidate found by name lookup is
'baselib::ReentrantLock'
class ReentrantLock
^
C:\Users\iosav\Documents\libil2cpp\il2cpp-object-internals.h:44:11: note: candidate found by name lookup is
'baselib::il2cpp_baselib::ReentrantLock'
class ReentrantLock;
^
1 error generated.
C:\iOS\builder\Toolchain>

append delete #20. Pierre-Marie Baty

Have you tried obtaining the logs of an Android build ? Normally, the compiler flags should be similar. That would tell you the right include order.

append delete #21. Trix

I will try this. Thanks

append delete #22. Trix

Logs seem to don’t include how the source has been builded unfortunately.

append delete #23. Trix

I’ve write a Python script that try all combinations possible all orders give same compilation error.

append delete #24. Pierre-Marie Baty

You can get the information elseway. Through process sniffing for example. Loop through the process list programmatically and extract the arguments of all created compiler processes while your library is being built.

append delete #25. Trix

I think it’s much works for something that should be much easier to done I guess I will give up for now.

append delete #26. Pierre-Marie Baty

I understand. Unfortunately if Unity doesn’t provide any information on how they built that library, you might not be able to guess it without that sort of work.

append delete #27. Trix

Yes unfortunately, but at least my game will be protected on android which is probably the worst plateform. Thanks for all the help provided.

append delete #28. Pierre-Marie Baty

You're welcome. When you'll want to give it another try, I'm confident the process monitoring technique to reconstruct your library's build command line will yield everything you need. It's always best to start from something that works and derivate from there.

append delete #29. Trix

Yes your probably true and I’ll definitely do that once I will re give a try. Probably after the first release of my mobile game, better to work on content and quality of the game than protection for now.

Have a nice day.

Reply

(Leave this as-is, it’s a trap!)

There is no need to “register”, just enter the same name + password of your choice every time.

Pro tip: Use markup to add links, quotes and more.

Moderators: Pierre-Marie Baty