Skip to content

Commit f6ea381

Browse files
Added notes on compiling OS X libwebsockets
1 parent 6263e24 commit f6ea381

File tree

5 files changed

+490
-0
lines changed

5 files changed

+490
-0
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,26 @@ cd build
138138
cmake .. -DLWS_IPV6=OFF
139139
make
140140
```
141+
### iOS
142+
* Clone libwebsockets
143+
* Clone this repo; it contains compiling resources in ofxLibwebsockets/extras/ios_libwebsockets
144+
* The toolchain in this folder will allow you to create an iOS XCode project
145+
* NOTE: CMake is not my specialty, so this file is currently hard-coded to use iOS 8.0... change line 89 if you'd like to use a different iOS
146+
* Create Xcode projects
147+
```
148+
cd /path/to/libwebsockets
149+
mkdir build
150+
cd build
151+
cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/ofxLibwebsockets/extras/ios_libwebsockets/toolchain/iOS.cmake -GXcode ..
152+
```
153+
* Replace lws_config.h in your build folder with the one at ofxLibwebsockets/extras/ios_libwebsockets/lws_config.h
154+
* Open the Xcode project in your build folder
155+
* Select the target 'websockets' (instead of ALL_BUILD) and select iOS Device as your target
156+
* Click on the scheme and select "Edit Scheme"
157+
* Set the Build Configuration to "Release"
158+
* Build the project
159+
* Copy the lib into place:
160+
```
161+
cd /path/to/your/build/folder
162+
cp lib/Relase/libwebsockets.a /PATH/TO/OF/addons/ofxLibwebsockets/libs/libwebsockets/lib/iosarmv7/libwebsockets.a
163+
```

extras/ios_libwebsockets/HOWTO.txt

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
#summary Guide to the ios-cmake project
2+
3+
4+
5+
== Introduction ==
6+
7+
8+
9+
This project provides a simple iOS toolchain file that may be used with CMake to build libraries.
10+
11+
12+
13+
14+
15+
== Contents ==
16+
17+
18+
19+
* [#Toolchain_file]
20+
21+
* [#Sample_library]
22+
23+
* [#Sample_application]
24+
25+
26+
27+
28+
29+
==Toolchain_file==
30+
31+
32+
33+
The toolchain is located in at toolchain/iOS.cmake location. Using the toolchain is quite straightforward. It only requires you to call CMake with:
34+
35+
36+
37+
{{{
38+
39+
cmake -DCMAKE_TOOLCHAIN_FILE=path/to/iOS.cmake -GXcode
40+
41+
}}}
42+
43+
44+
45+
*NOTE:* Since this toolchain by default builds both arm6 and arm7 fat libraries and applications, you need to use the Xcode generator. Makefiles currently do not work.
46+
47+
48+
49+
The iOS.cmake file only has a few different options, all of which are documented in the file itself.
50+
51+
52+
53+
54+
55+
===IOS_PLATFORM===
56+
57+
58+
59+
*Values:* OS (default) or SIMULATOR
60+
61+
62+
63+
This decides if SDKS will be selected from the iPhoneOS.platform or iPhoneSimulator.platform folders
64+
65+
* OS - the default, used to build for iPhone and iPad physical devices, which have an arm arch.
66+
67+
* SIMULATOR - used to build for the Simulator platforms, which have an x86 arch.
68+
69+
70+
71+
===CMAKE_IOS_DEVELOPER_ROOT===
72+
73+
74+
75+
*Values:* automatic(default) or /path/to/platform/ eveloper folder
76+
77+
78+
79+
By default this location is automatically chosen based on the IOS_PLATFORM value above. If set manually, it will override the default location and force the user of a particular Developer Platform
80+
81+
82+
83+
===CMAKE_IOS_SDK_ROOT===
84+
85+
86+
87+
*Values:* automatic(default) or /path/to/platform/Developer/SDKs/SDK folder
88+
89+
90+
91+
By default this location is automatically chosen based on the CMAKE_IOS_DEVELOPER_ROOT value. In this case it will always be the most up-to-date SDK found in the CMAKE_IOS_DEVELOPER_ROOT path. If set manually, this will force the use of a specific SDK version
92+
93+
94+
95+
96+
97+
==Sample_library==
98+
99+
100+
101+
The iOS.cmake toolchain is great for building libraries.
102+
103+
104+
105+
A sample library is located in the samples/hello-lib location. It creates a small static sample library. You can build the library in the standard CMake way using a build subdirectory:
106+
107+
108+
109+
{{{
110+
111+
1. mkdir build.ios
112+
113+
2. cd build.ios
114+
115+
3. cmake -DCMAKE_TOOLCHAIN_FILE=../../../toolchains/iOS.cmake -GXcode ..
116+
117+
4a. Open XCode and build the install target or
118+
119+
4b. Simply type: xcodebuild -target install -configuration Debug
120+
121+
}}}
122+
123+
124+
125+
This will place the library and header file into the samples/hello-app folder.
126+
127+
128+
129+
130+
131+
==Sample_application==
132+
133+
134+
135+
The sample application is located in samples/hello-app. This application uses the library and headers from the hello-lib project which are automatically installed if you built the install target.
136+
137+
138+
139+
Simply open the included Xcode project and build the application for whichever platform you created the build-lib target for (OS or SIMULATOR). Note that you will need to sign the application to deploy it to a device.
140+
141+
142+
143+
*NOTE:* Building an iOS executable application strictly using cmake is not a great idea. There are a large number of options that need to be setup within XCode before a project can simply be deployed onto a device. The whole signing process is a good example. For this reason, we do not attempt to build the hello-app sample using cmake.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
This project provides a simple iOS toolchain file that may be used with CMake to build libraries and setup applications. A couple of sample projects are included.
2+
3+
The iOS toolchain file was developed during the porting of the toadlet engine to iOS platforms. It is also used in that project.
4+
5+
See the included HOWTO.txt file for details.
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
/* config.h.in. Generated from configure.ac by autoheader. */
2+
3+
#ifndef WIN32
4+
#define _DEBUG
5+
#endif
6+
7+
/* Define to 1 to use CyaSSL as a replacement for OpenSSL.
8+
* LWS_OPENSSL_SUPPORT needs to be set also for this to work. */
9+
/* #undef USE_CYASSL */
10+
11+
/* The Libwebsocket version */
12+
#define LWS_LIBRARY_VERSION "1.3"
13+
14+
/* The current git commit hash that we're building from */
15+
/* #undef LWS_BUILD_HASH */
16+
17+
/* Build with OpenSSL support */
18+
#define LWS_OPENSSL_SUPPORT
19+
20+
/* The client should load and trust CA root certs it finds in the OS */
21+
#define LWS_SSL_CLIENT_USE_OS_CA_CERTS
22+
23+
/* Sets the path where the client certs should be installed. */
24+
#define LWS_OPENSSL_CLIENT_CERTS "../share"
25+
26+
/* Turn off websocket extensions */
27+
/* #undef LWS_NO_EXTENSIONS */
28+
29+
/* Enable libev io loop */
30+
/* #undef LWS_USE_LIBEV */
31+
32+
/* Build with support for ipv6 */
33+
#define LWS_USE_IPV6
34+
35+
/* Build with support for HTTP2 */
36+
/* #undef LWS_USE_HTTP2 */
37+
38+
/* Turn on latency measuring code */
39+
/* #undef LWS_LATENCY */
40+
41+
/* Don't build the daemonizeation api */
42+
/* #undef LWS_NO_DAEMONIZE */
43+
44+
/* Build without server support */
45+
/* #undef LWS_NO_SERVER */
46+
47+
/* Build without client support */
48+
/* #undef LWS_NO_CLIENT */
49+
50+
/* If we should compile with MinGW support */
51+
/* #undef LWS_MINGW_SUPPORT */
52+
53+
/* Use the BSD getifaddrs that comes with libwebsocket, for uclibc support */
54+
#define LWS_BUILTIN_GETIFADDRS
55+
56+
/* Define to 1 if you have the `bzero' function. */
57+
/* #undef HAVE_BZERO */
58+
59+
/* Define to 1 if you have the <dlfcn.h> header file. */
60+
/* #undef HAVE_DLFCN_H */
61+
62+
/* Define to 1 if you have the <fcntl.h> header file. */
63+
/* #undef HAVE_FCNTL_H */
64+
65+
/* Define to 1 if you have the `fork' function. */
66+
/* #undef HAVE_FORK */
67+
68+
/* Define to 1 if you have the `getenv’ function. */
69+
/* #undef HAVE_GETENV */
70+
71+
/* Define to 1 if you have the <in6addr.h> header file. */
72+
/* #undef HAVE_IN6ADDR_H */
73+
74+
/* Define to 1 if you have the <inttypes.h> header file. */
75+
/* #undef HAVE_INTTYPES_H */
76+
77+
/* Define to 1 if you have the `ssl' library (-lssl). */
78+
/* #undef HAVE_LIBSSL */
79+
80+
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
81+
to 0 otherwise. */
82+
/* #undef HAVE_MALLOC */
83+
84+
/* Define to 1 if you have the <memory.h> header file. */
85+
/* #undef HAVE_MEMORY_H */
86+
87+
/* Define to 1 if you have the `memset' function. */
88+
/* #undef HAVE_MEMSET */
89+
90+
/* Define to 1 if you have the <netinet/in.h> header file. */
91+
/* #undef HAVE_NETINET_IN_H */
92+
93+
/* Define to 1 if your system has a GNU libc compatible `realloc' function,
94+
and to 0 otherwise. */
95+
/* #undef HAVE_REALLOC */
96+
97+
/* Define to 1 if you have the `socket' function. */
98+
/* #undef HAVE_SOCKET */
99+
100+
/* Define to 1 if you have the <stdint.h> header file. */
101+
/* #undef HAVE_STDINT_H */
102+
103+
/* Define to 1 if you have the <stdlib.h> header file. */
104+
/* #undef HAVE_STDLIB_H */
105+
106+
/* Define to 1 if you have the `strerror' function. */
107+
/* #undef HAVE_STRERROR */
108+
109+
/* Define to 1 if you have the <strings.h> header file. */
110+
/* #undef HAVE_STRINGS_H */
111+
112+
/* Define to 1 if you have the <string.h> header file. */
113+
/* #undef HAVE_STRING_H */
114+
115+
/* Define to 1 if you have the <sys/prctl.h> header file. */
116+
/* #undef HAVE_SYS_PRCTL_H */
117+
118+
/* Define to 1 if you have the <sys/socket.h> header file. */
119+
/* #undef HAVE_SYS_SOCKET_H */
120+
121+
/* Define to 1 if you have the <sys/stat.h> header file. */
122+
/* #undef HAVE_SYS_STAT_H */
123+
124+
/* Define to 1 if you have the <sys/types.h> header file. */
125+
/* #undef HAVE_SYS_TYPES_H */
126+
127+
/* Define to 1 if you have the <unistd.h> header file. */
128+
/* #undef HAVE_UNISTD_H */
129+
130+
/* Define to 1 if you have the `vfork' function. */
131+
/* #undef HAVE_VFORK */
132+
133+
/* Define to 1 if you have the <vfork.h> header file. */
134+
/* #undef HAVE_VFORK_H */
135+
136+
/* Define to 1 if `fork' works. */
137+
#define HAVE_WORKING_FORK
138+
139+
/* Define to 1 if `vfork' works. */
140+
#define HAVE_WORKING_VFORK
141+
142+
/* Define to 1 if you have the <zlib.h> header file. */
143+
/* #undef HAVE_ZLIB_H */
144+
145+
/* Define to the sub-directory in which libtool stores uninstalled libraries.
146+
*/
147+
#undef LT_OBJDIR // We're not using libtool
148+
149+
/* Define to 1 if you have the ANSI C header files. */
150+
/* #undef STDC_HEADERS */
151+
152+
/* Version number of package */
153+
#define VERSION
154+
155+
/* Define to rpl_malloc if the replacement function should be used. */
156+
//#define malloc
157+
158+
/* Define to `int' if <sys/types.h> does not define. */
159+
//#define pid_t
160+
161+
/* Define to rpl_realloc if the replacement function should be used. */
162+
//#define realloc
163+
164+
/* Define to `unsigned int' if <sys/types.h> does not define. */
165+
//#ifndef _SIZE_T
166+
//#define _SIZE_T
167+
//typedef __darwin_size_t size_t
168+
//#endif
169+
170+
/* Define to 1 if we have getifaddrs */
171+
/* #undef HAVE_GETIFADDRS */
172+
173+
/* Define as `fork' if `vfork' does not work. */
174+
/* #undef vfork */
175+
176+
/* Define if the inline keyword doesn't exist. */
177+
/* #undef inline */

0 commit comments

Comments
 (0)