00001 # Rebuilding gclibo {#gclibo}
00002
00003 gclib ships with a compiled version of the open source portion, gclibo. However, if a source modification is desired,
00004 the following instructions will help with recompiling this portion of the library.
00005
00006 <!--- *********************************************************************************** -->
00007 ***
00008 ## Windows
00009 ***
00010 <!--- *********************************************************************************** -->
00011
00012 For brevity, these instructions assume the default installation location of **C:\\Program Files (x86)\\Galil\\gclib** and a build type of **x86 (win32)**.
00013 The following instructions were performed on *Visual Studio Professional 2013* and can be extended to other Visual Studio versions.
00014
00015 Open *VS2013 x86 Native Tools Command Prompt*.
00016
00017 ###Copy files
00018 Navigate to a convenient, empty, writable location, e.g. *C:\\temp*.
00019
00020 ####Set an environment variable for the base path.
00021
00022 C:\temp>set base=C:\Program Files (x86)\Galil\gclib
00023
00024 ####Copy the source files. **Note the quotes.**
00025
00026 C:\temp>copy "%base%\source\gclibo\*.c" .
00027
00028 ###Modify source
00029 Make any necessary changes. For this example, the GInfo() function was changed from
00030
00031 \code{.c}
00032 GReturn GCALL GInfo(GCon g, GCStringOut info, GSize info_len)
00033 {
00034 return GUtility(g, G_UTIL_INFO, info, &info_len);
00035 }
00036 \endcode
00037
00038 to
00039
00040 \code{.c}
00041 GReturn GCALL GInfo(GCon g, GCStringOut info, GSize info_len)
00042 {
00043 strncpy(info, "My controller", info_len);
00044 return G_NO_ERROR;
00045
00046 }
00047 \endcode
00048
00049 ###Compile and copy
00050
00051 ####Compile the source code. **Note the quotes.**
00052
00053 C:\temp>cl -c *.c -I "%base%\include" -DBUILDING_GCLIB
00054
00055 ####Link the source code. **Note the quotes.**
00056
00057 C:\temp>link /DLL *.obj "%base%\lib\dynamic\x86\gclib.lib" /OUT:gclibo.dll
00058
00059 ####Copy
00060 Copy back to the installation location from the file explorer.
00061
00062 * Copy gclibo.lib to "C:\Program Files (x86)\Galil\gclib\lib\dynamic\x86"
00063 * Copy gclibo.dll to "C:\Program Files (x86)\Galil\gclib\dll\x86"
00064
00065 ###Test
00066
00067 ####Copy simple example
00068
00069 C:\temp>copy "%base%\examples\cpp\x_simple.c" .
00070
00071 ####Edit GOpen() call as necessary
00072 ####Compile
00073
00074 C:\temp>cl x_simple.c "%base%\lib\dynamic\x86\*.lib" -I "%base%\include"
00075
00076 ####Set Path to DLL
00077
00078 C:\temp>set PATH=%base%\dll\x86\;%PATH%
00079
00080 ####Execute
00081
00082 C:\temp>x_simple.exe
00083 rc: 0
00084 version: 85.60.138
00085 rc: 0
00086 rc: 0
00087 info: My controller
00088 rc: 0
00089 response: 355000958.0000
00090 :
00091
00092
00093
00094
00095 <!--- *********************************************************************************** -->
00096 ***
00097 ## Linux
00098 ***
00099 <!--- *********************************************************************************** -->
00100
00101
00102 ###Copy files
00103
00104 $ mkdir test
00105 $ cd test
00106 $ tar -xvf /usr/share/doc/gclib/src/gclibo_164_src.tar.gz
00107 gclibo.h
00108 gclibo.c
00109 arrays.c
00110 makefile_gclibo
00111 $ cp /usr/include/gclib*.h .
00112 $ ls
00113 arrays.c gclib.h gclibo.h makefile_gclibo
00114 gclib_errors.h gclibo.c gclib_record.h
00115
00116
00117 ###Modify source
00118 Make any necessary changes. For this example, the GInfo() function was changed from
00119
00120 \code{.c}
00121 GReturn GCALL GInfo(GCon g, GCStringOut info, GSize info_len)
00122 {
00123 return GUtility(g, G_UTIL_INFO, info, &info_len);
00124 }
00125 \endcode
00126
00127 to
00128
00129 \code{.c}
00130 GReturn GCALL GInfo(GCon g, GCStringOut info, GSize info_len)
00131 {
00132 strncpy(info, "My controller", info_len);
00133 return G_NO_ERROR;
00134
00135 }
00136 \endcode
00137
00138 ###Make and install
00139
00140 $ make -f makefile_gclibo
00141 Open source component, libgclibo.so.0.0
00142 Compiling open source component.
00143 gcc -c -Wall -Werror -fPIC -fvisibility=hidden -DBUILDING_GCLIB -DHAVE_VISIBILITY *.c
00144 Linking open source component into shared library.
00145 gcc -shared -o libgclibo.so.0.0 *.o -Wl,-soname=libgclibo.so.0
00146 strip --strip-unneeded libgclibo.so.0.0
00147 Cleaning up.
00148 $ sudo make install -f makefile_gclibo
00149 Installing libgclibo.so.0.0
00150 install -m 755 libgclibo.so.0.0 /usr/lib
00151 ldconfig
00152 $ make clean -f makefile_gclibo
00153 Cleaning project...
00154
00155
00156 ###Test
00157
00158 ####Extract simple example
00159
00160 $ tar -xzf /usr/share/doc/gclib/src/gclib_165_examples.tar.gz x_simple.c
00161
00162 #### Edit GOpen() call as necessary.
00163 #### Compile
00164
00165 $ gcc x_simple.c -Wall -Werror -lgclib -lgclibo -o simple
00166
00167 ####Execute
00168
00169 $ ./simple
00170 rc: 0
00171 version: 85.60.131
00172 rc: 0
00173 rc: 0
00174 info: My controller
00175 rc: 0
00176 response: 182879322.0000
00177 :
00178
00179
00180 <!--- *********************************************************************************** -->
00181 ***
00182 ## OS X
00183 ***
00184 <!--- *********************************************************************************** -->
00185
00186
00187 ###Copy files
00188
00189 $ mkdir test
00190 $ cd test
00191 $ tar -xvf /Applications/gclib/source/gclibo_253_src.tar.gz x gclibo.h
00192 x gclibo.c
00193 x arrays.c
00194 x makefile_gclibo
00195 $ cp /Applications/gclib/include
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263