Re: [Openvpn-devel] [PATCH v3 2/3] Build unit tests in mingw Windows build

2023-02-11 Thread Selva Nair
Hi,

On Sat, Feb 11, 2023 at 1:32 PM Gert Doering  wrote:

>
>
> /bin/bash ../../../libtool  --tag=CC   --mode=link i686-w64-mingw32-gcc


This is a 32 bit build which I never tried. Maybe cmocka is not built for
32 bit?


> -I/home/gert/mingw/opt/include  -I/home/gert/mingw/opt/include
> -I../../../include -I/home/gert/mingw/opt/include -Wall
> -Wno-stringop-truncation -I/home/gert/mingw/opt/include -std=c99
> -L/home/gert/mingw/lib -L/home/gert/mingw/opt/lib64 -lssl -lcrypto
> -L/home/gert/mingw/opt/lib -llzo2 -L/home/gert/mingw/opt/lib -lcmocka
> -L/home/gert/mingw/opt/lib -o example_testdriver.exe
> example_testdriver-test.o
> libtool: link: i686-w64-mingw32-gcc -I/home/gert/mingw/opt/include
> -I/home/gert/mingw/opt/include -I../../../include
> -I/home/gert/mingw/opt/include -Wall -Wno-stringop-truncation
> -I/home/gert/mingw/opt/include -std=c99 -o .libs/example_testdriver.exe
> example_testdriver-test.o  -L/home/gert/mingw/lib
> -L/home/gert/mingw/opt/lib64 -lssl -lcrypto -L/home/gert/mingw/opt/lib
> /home/gert/mingw/opt/lib/liblzo2.a -lwinmm -lcmocka
> /usr/bin/i686-w64-mingw32-ld:
> example_testdriver-test.o:test.c:(.text+0x89): undefined reference to
> `_assert_int_equal'
> /usr/bin/i686-w64-mingw32-ld:
> example_testdriver-test.o:test.c:(.text+0xc6): undefined reference to
> `_assert_int_equal'
> /usr/bin/i686-w64-mingw32-ld:
> example_testdriver-test.o:test.c:(.text+0x153): undefined reference to
> `_cmocka_run_group_tests'
>

I had seen something similar with  the master branch -- the def had some
functions missing. But 1.1.5 worked out of the box.

Selva
___
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel


Re: [Openvpn-devel] [PATCH v3 2/3] Build unit tests in mingw Windows build

2023-02-11 Thread Gert Doering
Hi,

On Fri, Feb 10, 2023 at 06:10:41PM -0500, Selva Nair wrote:
> Ignore the previous email  -- (I behaved as if I can't read more than a
> pageful).

:-)

> Looks like unit-tests are not enabled during configure. For that, cmocka
> should be available in the search path or set using CMOCKA_LIBS and
> CMOCKA_INCLUDES.

Yes, that's the conclusion I arrived at, after I sent yesterday's
mail and went to bed - "oh no, it can't do anything, there is no cmocka
in that cross-compile environment".  But I didn't want to get up again
just to send that followup mail ;-)

> It took a while for me to figure out how to cross-compile cmocka using
> cmake and mingw on Linux. Finally what worked was pretty simple:
> 
> git clone https://github.com/clibs/cmocka.git
> cd cmocka
> checkout cmocka-1.1.5
> mkdir build
> cd build
> cmake -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc
> \
> -DCMAKE_SHARED_LINKER_FLAGS=-static-libgcc \
> -DCMAKE_INSTALL_PREFIX=$HOME/mingw-cmocka/ -S .. -B .
> make install

This would have been my next question "how do I build this?" :-)

... adapted to my build environment...

-- Installing: /home/gert/mingw/opt/include/cmocka.h
-- Installing: /home/gert/mingw/opt/bin/cmocka.dll

... then returning to openvpn & re-running configure, it will
still not find it :-(

checking for CMOCKA... no
configure: WARNING: cmocka.pc not found on the system.  Unit tests disabled

... so, configure CMOCKA_CFLAGS/CMOCKA_LIBS it is...

checking for CMOCKA... yes

... but then trying to build the test drivers fails, and from the looks
of it, it's finding but not utilizing the cmocka lib...

/bin/bash ../../../libtool  --tag=CC   --mode=link i686-w64-mingw32-gcc 
-I/home/gert/mingw/opt/include  -I/home/gert/mingw/opt/include 
-I../../../include -I/home/gert/mingw/opt/include -Wall 
-Wno-stringop-truncation -I/home/gert/mingw/opt/include -std=c99 
-L/home/gert/mingw/lib -L/home/gert/mingw/opt/lib64 -lssl -lcrypto  
-L/home/gert/mingw/opt/lib -llzo2 -L/home/gert/mingw/opt/lib -lcmocka 
-L/home/gert/mingw/opt/lib -o example_testdriver.exe example_testdriver-test.o  
libtool: link: i686-w64-mingw32-gcc -I/home/gert/mingw/opt/include 
-I/home/gert/mingw/opt/include -I../../../include 
-I/home/gert/mingw/opt/include -Wall -Wno-stringop-truncation 
-I/home/gert/mingw/opt/include -std=c99 -o .libs/example_testdriver.exe 
example_testdriver-test.o  -L/home/gert/mingw/lib -L/home/gert/mingw/opt/lib64 
-lssl -lcrypto -L/home/gert/mingw/opt/lib /home/gert/mingw/opt/lib/liblzo2.a 
-lwinmm -lcmocka
/usr/bin/i686-w64-mingw32-ld: example_testdriver-test.o:test.c:(.text+0x89): 
undefined reference to `_assert_int_equal'
/usr/bin/i686-w64-mingw32-ld: example_testdriver-test.o:test.c:(.text+0xc6): 
undefined reference to `_assert_int_equal'
/usr/bin/i686-w64-mingw32-ld: example_testdriver-test.o:test.c:(.text+0x153): 
undefined reference to `_cmocka_run_group_tests'
collect2: error: ld returned 1 exit status
make[5]: *** [Makefile:461: example_testdriver.exe] Error 1

... tried various permutations of "-L$path -lcmocka", putting the
actual path to "libcmocka.dll.a" on the link/libtool command line, but
the error never changes...

*scratch head*

Need to debug this more tonight...

gert
-- 
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
 Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany g...@greenie.muc.de


signature.asc
Description: PGP signature
___
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel