How to tell Autoconf "require symbol A or B" from LIB? - symbols

I'm trying to configure Postgres 9.5.4 for OpenSSL 1.1.0. Configure is dying because it can't find SSL_library_init in OpenSSL 1.1.0. OpenSSL 1.1.0 provides OPENSSL_init_ssl instead of SSL_library_init. So Autoconf needs to check for either SSL_library_init or OPENSSL_init_ssl.
Postgres uses the following test:
AC_CHECK_LIB(ssl, SSL_library_init, [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
How do I modify that [rule?] to look for either SSL_library_init or OPENSSL_init_ssl?
Naively, I changed configure.in to the following, which did not work. The best I can tell, my changes were ignored (even after running autoreconf):
AC_CHECK_LIB(ssl, SSL_library_init|OPENSSL_init_ssl, [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
Here is the Postgrs configure command:
$ ./configure --with-openssl --with-includes=/usr/local/ssl/include --with-libraries=/usr/local/ssl/lib
Here is the relevant entry from config.log:
configure:8732: gcc -o conftest -Wall -Wmissing-prototypes -Wpointer-arith
-Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute
-Wformat-security -fno-strict-aliasing -fwrapv
-Wno-unused-command-line-argument -I/usr/local/ssl/include
-L/usr/local/ssl/lib -I/usr/local/ssl/include -L/usr/local/ssl/lib
conftest.c -lssl -lcrypto -lz -lreadline -lm >&5
Undefined symbols for architecture x86_64:
"_SSL_library_init", referenced from:
_main in conftest-c0c2a1.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
configure:8732: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "PostgreSQL"
| #define PACKAGE_TARNAME "postgresql"
| #define PACKAGE_VERSION "9.5.4"
| #define PACKAGE_STRING "PostgreSQL 9.5.4"
| #define PACKAGE_BUGREPORT "pgsql-bugs(at)postgresql(dot)org"
| #define PACKAGE_URL ""
| #define PG_MAJORVERSION "9.5"
| #define PG_VERSION "9.5.4"
| #define USE_INTEGER_DATETIMES 1
| #define DEF_PGPORT 5432
| #define DEF_PGPORT_STR "5432"
| #define BLCKSZ 8192
| #define RELSEG_SIZE 131072
| #define XLOG_BLCKSZ 8192
| #define XLOG_SEG_SIZE (16 * 1024 * 1024)
| #define ENABLE_THREAD_SAFETY 1
| #define PG_KRB_SRVNAM "postgres"
| #define USE_OPENSSL 1
| #define HAVE_LIBM 1
| #define HAVE_LIBREADLINE 1
| #define HAVE_LIBZ 1
| #define HAVE_SPINLOCKS 1
| #define HAVE_ATOMICS 1
| #define HAVE_LIBCRYPTO 1
| /* end confdefs.h. */
|
| /* Override any GCC internal prototype to avoid an error.
| Use char because int might match the return type of a GCC
| builtin and then its argument prototype would still apply. */
| #ifdef __cplusplus
| extern "C"
| #endif
| char SSL_library_init ();
| int
| main ()
| {
| return SSL_library_init ();
| ;
| return 0;
| }
configure:8741: result: no
configure:8751: error: library 'ssl' is required for OpenSSL

Something like this should work out for you:
ACCEPT_SSL_LIB="no"
AC_CHECK_LIB(ssl, OPENSSL_init_ssl, [ACCEPT_SSL_LIB="yes"])
AC_CHECK_LIB(ssl, SSL_library_init, [ACCEPT_SSL_LIB="yes"])
AS_IF([test "x$ACCEPT_SSL_LIB" = xno], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
You may need another variable to tell you what init function to call, to set up SSL, unless there's some macro magic in a header file that will actually fix it up to the right value.

To build upon #ldav1s' answer, here are the changes to configure.in required to get past configuration. Once configure.in is modified, autoreconf should be run.
$ git diff configure.in > configure.in.diff
$ cat configure.in.diff
diff --git a/configure.in b/configure.in
index c878b4e..7ba7538 100644
--- a/configure.in
+++ b/configure.in
## -1112,10 +1112,16 ## if test "$with_openssl" = yes ; then
dnl Order matters!
if test "$PORTNAME" != "win32"; then
AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])])
- AC_CHECK_LIB(ssl, SSL_library_init, [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
+ FOUND_SSL_LIB="no"
+ AC_CHECK_LIB(ssl, OPENSSL_init_ssl, [FOUND_SSL_LIB="yes"])
+ AC_CHECK_LIB(ssl, SSL_library_init, [FOUND_SSL_LIB="yes"])
+ AS_IF([test "x$FOUND_SSL_LIB" = xno], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
else
AC_SEARCH_LIBS(CRYPTO_new_ex_data, eay32 crypto, [], [AC_MSG_ERROR([library 'eay32' or 'crypto' is required for OpenSSL])])
- AC_SEARCH_LIBS(SSL_library_init, ssleay32 ssl, [], [AC_MSG_ERROR([library 'ssleay32' or 'ssl' is required for OpenSSL])])
+ FOUND_SSL_LIB="no"
+ AC_SEARCH_LIBS(OPENSSL_init_ssl, ssleay32 ssl, [FOUND_SSL_LIB="yes"])
+ AC_SEARCH_LIBS(SSL_library_init, ssleay32 ssl, [FOUND_SSL_LIB="yes"])
+ AS_IF([test "x$FOUND_SSL_LIB" = xno], [AC_MSG_ERROR([library 'ssleay32' or 'ssl' is required for OpenSSL])])
fi
AC_CHECK_FUNCS([SSL_get_current_compression])
fi

Related

clang not generating debug symbols

I have a a.c
#include <stdio.h>
int main() {
int a = 1;
int b = 2;
int c = a + b;
return 0;
}
when compiling with clang -g a.c, I can't get debug symbols.
joey#voyager-arch /t/a4> lldb a.out
(lldb) target create "a.out"
Current executable set to '/tmp/a4/a.out' (x86_64).
(lldb) l
(lldb)
But if I use gcc, I can successfully got the debug symbols, compile with gcc -g a.c
joey#voyager-arch /t/a4> gdb a.out
GNU gdb (GDB) 11.1
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from a.out...
(gdb) l
1 #include <stdio.h>
2
3 int main() {
4 int a = 1;
5 int b = 2;
6 int c = a + b;
7 return 0;
8 }
(gdb)
I'm using archlinux with amd ryzen 7 cpu.
clang: 12.0.1
lldb: 12.0.1
gcc: 11.1.0
gdb: 11.1
May be a lldb 12 incompatible bug, downgrade to lldb 10 solved this problem.

How do I go build a Go GTK 2 app for Windows from Linux? Is there a Docker image?

I am trying to cross-compile a .go file for the GTK binding package Linux => Windows and can't figure it out. Tried going the route of setting up MSYS on Win but it was god-awful.
I looked for a Docker image but there is none.
$ ~/go/src/gui$ GOOS=windows CGO_ENABLED=1 GOARCH= CC=x86_64-w64-mingw32-gcc go build
# github.com/mattn/go-gtk/glib
In file included from /usr/lib/x86_64-linux-gnu/glib-2.0/include/glibconfig.h:9:0,
from /usr/include/glib-2.0/glib/gtypes.h:32,
from /usr/include/glib-2.0/glib/galloca.h:32,
from /usr/include/glib-2.0/glib.h:30,
from ./glib.go.h:4,
from ../github.com/mattn/go-gtk/glib/glib.go:5:
/usr/include/glib-2.0/glib/gtypes.h: In function '_GLIB_CHECKED_ADD_U64':
/usr/include/glib-2.0/glib/gmacros.h:241:53: error: size of array '_GStaticAssertCompileTimeAssertion_0' is negative
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
^
/usr/include/glib-2.0/glib/gmacros.h:238:47: note: in definition of macro 'G_PASTE_ARGS'
#define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
^~~~~~~~~~~
/usr/include/glib-2.0/glib/gmacros.h:241:44: note: in expansion of macro 'G_PASTE'
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
^~~~~~~
/usr/include/glib-2.0/glib/gtypes.h:423:3: note: in expansion of macro 'G_STATIC_ASSERT'
G_STATIC_ASSERT(sizeof (unsigned long long) == sizeof (guint64));
^~~~~~~~~~~~~~~
# github.com/mattn/go-gtk/pango
In file included from /usr/lib/x86_64-linux-gnu/glib-2.0/include/glibconfig.h:9:0,
from /usr/include/glib-2.0/glib/gtypes.h:32,
from /usr/include/glib-2.0/glib/galloca.h:32,
from /usr/include/glib-2.0/glib.h:30,
from /usr/include/pango-1.0/pango/pango-coverage.h:25,
from /usr/include/pango-1.0/pango/pango-font.h:25,
from /usr/include/pango-1.0/pango/pango-attributes.h:25,
from /usr/include/pango-1.0/pango/pango.h:25,
from ./pango.go.h:7,
from ../github.com/mattn/go-gtk/pango/pango.go:5:
/usr/include/glib-2.0/glib/gtypes.h: In function '_GLIB_CHECKED_ADD_U64':
/usr/include/glib-2.0/glib/gmacros.h:241:53: error: size of array '_GStaticAssertCompileTimeAssertion_0' is negative
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
^
/usr/include/glib-2.0/glib/gmacros.h:238:47: note: in definition of macro 'G_PASTE_ARGS'
#define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2
^~~~~~~~~~~
/usr/include/glib-2.0/glib/gmacros.h:241:44: note: in expansion of macro 'G_PASTE'
#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED
^~~~~~~
/usr/include/glib-2.0/glib/gtypes.h:423:3: note: in expansion of macro 'G_STATIC_ASSERT'
G_STATIC_ASSERT(sizeof (unsigned long long) == sizeof (guint64));```

undefind reference to gst_element_register Qtcreator

I'm trying to build a program in which I use gstreamer and opencv to manipulate images. This is my main file:
#include "GstSource.hpp"
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/highgui/highgui_c.h>
#include <iostream>
static const int Key_Escape = 27;
int main(int argc, char *argv[])
{
cv::namedWindow("Gstreamer");
cvMoveWindow("Gstreamer",100,100);
GstreamerPlayer player;
if (! player.open("videotestsrc") )
std::cerr << "Unable to open pipeline" << std::endl;
if ( !player.setWidth(640) || !player.setHeight(480) ) {
std::cerr << "Unable to change resolution" << std::endl;
return 1;
}
bool fps_readed = false;
while (true) {
if (!player.grabFrame()) {
std::cerr << "Failed to grab frame" << std::endl;
break;
}
GstreamerImage * frame = player.getImage();
if (!frame) {
std::cerr << "Failed to retrieve frame" << std::endl;
break;
}
if (!fps_readed) {
std::cout << "Video playing at " << player.getFps() << " fps" < std::endl;
fps_readed = true;
}
cv::Mat canvas = cv::Mat(frame->height, frame->width, CV_8UC3, frame->data);
if ( canvas.empty() )
break;
cv::imshow("Gstreamer", canvas);
int key = cv::waitKey(10);
if (key == Key_Escape)
break;
}
}
and this is the .pro file:
QT += core
QT -= gui
TARGET = provaQT
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
INCLUDEPATH += /usr/include/gstreamer-1.0 \
/usr/local/include \
/usr/include/glib-2.0 \
/usr/lib/arm-linux-gnueabihf/glib-2.0/include \
/usr/lib/arm-linux-gnueabihf
LIBS += -L"/usr/lib/arm-linux-gnueabihf" -lglib-2.0 -lgobject-2.0 \
-L"/usr/local/lib" -lopencv_core -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_videoio \
-L"/usr/lib/arm-linux-gnueabihf/gstreamer-1.0" -lgnl -lgst1394 -lgstaasink -lgstaccurip -lgstcoreelements \
-L"/home/odroid/Desktop/Gstreamer-Test/bin/linux/gst-plugins" -lgst-overlay
SOURCES += \
../Gstreamer-Test/src/gstinit.cpp \
../Gstreamer-Test/src/gstplugin.cpp \
../Gstreamer-Test/src/gstplugin_impl.cpp \
../Gstreamer-Test/src/GstSource.cpp \
../Gstreamer-Test/src/main.cpp \
../Gstreamer-Test/src/videotestoverlay.cpp
HEADERS += \
../Gstreamer-Test/src/gstplugin.hpp \
../Gstreamer-Test/src/gstplugin_impl.hpp \
../Gstreamer-Test/src/GstSource.hpp \
../Gstreamer-Test/src/videotestoverlay.hpp
and I get 147 error of this type: undefined reference to..... because many function used are declared but not defined. Where are their definition? How I can include their definition?
What about using PKGCONFIG:
in your pro:
CONFIG += pkgconfig
PKGCONFIG += gstreamer-1.0 gstreamer-video-1.0
You can check from shell that you have them:
pkg-config --list-all | grep gst
Checking one package if pointing to correct libraries:
pkg-config --cflags gstreamer-1.0
Should print:
-pthread -I/usr/local/include/gstreamer-1.0 -I/usr/local/lib/gstreamer-1.0/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -L/usr/local/lib -lgstreamer-1.0 -lgobject-2.0 -lglib-2.0
If you do not have the .pc files they wont be listed.. You need to install the -dev version of the gstreamer packages.
Also there is env variable which can be used to tell pkg config where to look for .pc files:
PKG_CONFIG_PATH=/home/something/gst/1.6/gst-devtools/validate/pkgconfig
Here someone tried to link opencv that way..

Why does lemon not execute terminals immediately?

I am moving a small threaded interpreter using flex and yacc to re2c and lemon. Everything is working but literals.
Why does the action associated with literals fail to run as it does with yacc? I expect "1.0 end" but get "0.0 end"
dspgrammar.y
%include {#include <assert.h>}
%name dsp
%token_type {float}
program ::= expr. {printf("end\n");}
expr(val) ::= LITERAL. {printf("%f ", val);}
main.c
#include <stdio.h>
#include <stdlib.h>
#include "dspgrammar.h"
void *dspAlloc(void *(*)(size_t));
void dsp(void *, int, float);
void dspFree(void *, void (*)(void *));
void dspTrace(FILE *, char *);
int main(int argc, char *argv[])
{
void *parser = dspAlloc(malloc);
dspTrace(stderr, "TRACE: ");
dsp(parser, LITERAL, 1.0f);
dsp(parser, 0, 0.0f);
dspFree(parser, free);
return EXIT_SUCCESS;
}
Makefile
CC = gcc
CFLAGS = -O0 -g -Wall -Wextra -pedantic -std=gnu99
LD = gcc
LDFLAGS = -lm
dsp: main.o dspgrammar.o
$(LD) $(CFLAGS) -o $# $^ $(LDFLAGS)
main.o: main.c
$(CC) $(CFLAGS) -c main.c
dspgrammar.o: dspgrammar.c
$(CC) -c $(CFLAGS) -c dspgrammar.c
dspgrammar.c: dspgrammar.y
lemon dspgrammar.y
In
expr(val) ::= LITERAL. { /* something with val */ }
val is the name of the reduction value. In other words, it corresponds to $$ in yacc. The semantic value of the terminal LITERAL is $1, since you haven't provided a symbolic name for that value.
Perhaps you meant:
expr ::= LITERAL(val). { /* something with val */ }
Or
expr(e) ::= LITERAL(v). { e = v; /* some other action */ }

turn off Cocos2D verbose logging

I just upgraded to cocos 2.1, and am seeing a ridiculous amount of logging to the console, such as:
2013-09-18 23:15:38.120 Notes and Clefs[842:907] cocos2d: deallocing <CCSprite = 0x1182aa0 | Rect = (816.00,640.00,32.00,64.00) | tag = -1 | atlasIndex = -1>
2013-09-18 23:15:38.121 Notes and Clefs[842:907] cocos2d: deallocing <CCSprite = 0x1182600 | Rect = (816.00,128.00,32.00,64.00) | tag = -1 | atlasIndex = -1>
2013-09-18 23:15:38.122 Notes and Clefs[842:907] cocos2d: deallocing <CCArray = 0x1161e00> = ( <CCSprite = 0x1182790 | Rect = (816.00,640.00,32.00,64.00) | tag = -1 | atlasIndex = -1>, )
etc..
From looking at the code, I see:
#if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0
#define CCLOG(...) do {} while (0)
#define CCLOGWARN(...) do {} while (0)
#define CCLOGINFO(...) do {} while (0)
#elif COCOS2D_DEBUG == 1
#define CCLOG(...) __CCLOG(__VA_ARGS__)
#define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__)
#define CCLOGINFO(...) do {} while (0)
#elif COCOS2D_DEBUG > 1
#define CCLOG(...) __CCLOG(__VA_ARGS__)
#define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__)
#define CCLOGINFO(...) __CCLOG(__VA_ARGS__)
#endif // COCOS2D_DEBUG
And I set COCOS2D_DEBUG = 0, but I still get the same verbose logging...
I have Cocos2D in my project as a static library .a file.. Is it possible that this .a already has a macro/constant defined at level 2 or something, and that's why I'm seeing it not make any difference?
Can anyone recommend a way to turn this off?
Yes, when the static library is compiled using the Debug scheme, it'll print all these debug messages out. Try recompiling the static library with the COCOS2D_DEBUG preprocessor macro set to 1.
Why are you adding it as a static .a library though? I just add the cocos2d-ios.xcodeproj to my own project and add libcocos2d.a to Build Phases under Link Binary with Libraries. That way it'll automatically recompile cocos2d whenever a change occurs.

Resources