English 中文(简体)
Has anyone compiled GMock for iOS
原标题:

I am trying to compile GMock from sources for iOS. I want to compile it as an archive so that multiple iOS projects can use it. I am using cmake to build this module (the existing build system uses cmake to build GMock as dylibs, so its easier if I could use the same method). I had to add the following in CMakeLists.txt to build it as an archive.

set(BUILD_SHARED_LIBS OFF)

The archives are created but the problem is some of the tests (in gtest_build_tests) are failing.


The following tests FAILED:
 22 - gtest-filepath_test (SEGFAULT)
 51 - gtest_filter_unittest (Failed)
 54 - gtest_output_test (Failed)
 58 - gtest_xml_outfiles_test (Failed)
 59 - gtest_xml_output_unittest (Failed)
Errors while running CTest

Has anyone successfully built GMock as archive for iOS ?? If so how did you guys do it ?? Also I have to manage the build process from terminal without using Xcode or xcodebuild command.

Thanks, Abhinay

问题回答

Building GMock for iOS can indeed be a challenge due to the platform s specific requirements. If you re seeing test failures after building as a static library, it could be due to various reasons, including compilation settings, system configurations, or compatibility issues between GMock and the iOS platform.

Here s a general guideline on how you might approach building GMock for iOS from the terminal, making sure you set the right compiler and flags:

  1. Ensure that you have the correct version of iOS SDK installed on your machine. Also, make sure you have Xcode command line tools installed even though you are not using Xcode directly. They provide necessary compilers and libraries for building code for iOS.

  2. While configuring the build with CMake, you need to specify the toolchain file for the iOS platform. Here is an example of how you might set up the command:

cmake -H. -Bbuild -DCMAKE_TOOLCHAIN_FILE=/path/to/ios-cmake/toolchain.cmake -DIOS_PLATFORM=OS

Replace /path/to/ios-cmake/toolchain.cmake with the actual path to your iOS toolchain file. This toolchain file is responsible for setting up the right environment for iOS build.

  1. After configuration, start the build process using the following command:
cmake --build build --config Release

Remember that in this process, you are not only compiling GMock but also its dependency GoogleTest. If GoogleTest has any issues with the iOS platform, they might be the cause of your test failures.

If the test failures persist after following these steps, try to dig into the failure messages more. This could provide clues about what s causing the issues. Maybe there s a need for a patch to the source code, or there might be missing or incorrect flags in your build process.

Also, make sure you re using a version of GMock that s compatible with your iOS version. It might be helpful to check the GMock s issue tracker and user groups to see if others have encountered similar problems, as they might have found a solution or workaround.

Please note that the toolchain file can usually be found in a package like ios-cmake, which provides a toolchain file specifically tailored to iOS builds. You might need to download and install such a package if you haven t done so already.

Remember that GMock is primarily designed and tested for desktop platforms. While it usually works on mobile platforms like iOS, there can be unforeseen compatibility issues. If you continue encountering problems, it might be worth considering other testing frameworks that are explicitly designed to support iOS.





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签