Programs configured to use dmalloc bail-out citing header file error - header-files

While trying to compile lynx, I used the 'with-dmalloc' configure option. But compilation aborted, producing this error:
/usr/include/dmalloc.h:460: error: expected identifier or '(' before '__extension__'
> /usr/include/dmalloc.h:484: error: expected identifier or '(' before '__extension__'
> make[1]: *** [HTParse.o] Error 1
> make[1]: Leaving directory `/tmp/lynx2-8-8/WWW/Library/Implementation'
> make: *** [all] Error 2
This is what the errant lines in dmalloc.h hold:
> Line 460: char *strdup(const char *string);
> Linu 484: char *strndup(const char *string, const DMALLOC_SIZE len);
The file can also be viewed at http://www.filewatcher.com/p/dmalloc-5.5.2.tbz.467309/include/dmalloc.h.html
Development on dmalloc has pretty much stopped, so not really expecting a fix from upstream. Any help?

I faced with the similar problem while installing dmalloc on Fedora 21 x86_64:
dmalloc-5.5.2]$ make
rm -f dmalloc.h dmalloc.h.t
cat ./dmalloc.h.1 dmalloc.h.2 ./dmalloc.h.3 > dmalloc.h.t
mv dmalloc.h.t dmalloc.h
rm -f arg_check.o
gcc -g -O2 -DHAVE_STDARG_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 - DHAVE_UNISTD_H=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_SYS_TYPES_H=1 - DHAVE_W32API_WINBASE_H=0 -DHAVE_W32API_WINDEF_H=0 -DHAVE_SYS_CYGWIN_H=0 - DHAVE_SIGNAL_H=1 -I. -I. -c arg_check.c -o ./arg_check.o
In file included from /usr/include/string.h:634:0,
from arg_check.c:33:
dmalloc.h:484:7: error: expected identifier or ‘(’ before ‘__extension__’
char *strndup(const char *string, const DMALLOC_SIZE len);
^
Makefile:362: recipe for target 'arg_check.o' failed
make: *** [arg_check.o] Error 1
Solved it by altering dmalloc-5.5.2/dmalloc.h.3:
- 432 | extern
- 433 | char *strndup(const char *string, const DMALLOC_SIZE len);
+ 432 | #undef strndup
+ 433 | extern
+ 434 | char *strndup(const char *string, const DMALLOC_SIZE len);
The source of wisdom: https://dev.openwrt.org/browser/packages/devel/dmalloc/patches/400-undef-strndup.patch?rev=31253

I encountered something like this and found that this was caused by the dmalloc.h was included before e.g. <unistd.h> et. al so that the macro identifiers from dmalloc.h mangled the declarations for the real valloc/realloc/memdup etc.
Could this be what you are seeing?

Related

Bitcoin core libbitcoin_server_a-httpserver.o Error

I'm trying to install a custom fork of bitcoin core from HERE And when compiling, I get the following error:
I have installed all the prerequisites i think
Making all in src
make[1]: Entering directory '/home/muhammad/Programs/SimorghCoin/src'
make[2]: Entering directory '/home/muhammad/Programs/SimorghCoin/src'
CXX bitcoind-bitcoind.o
CXX libbitcoin_server_a-addrdb.o
CXX libbitcoin_server_a-addrman.o
CXX libbitcoin_server_a-bloom.o
CXX libbitcoin_server_a-blockencodings.o
CXX libbitcoin_server_a-blockfilter.o
CXX libbitcoin_server_a-chain.o
CXX libbitcoin_server_a-checkpoints.o
CXX consensus/libbitcoin_server_a-tx_verify.o
CXX libbitcoin_server_a-httprpc.o
CXX libbitcoin_server_a-httpserver.o
httpserver.cpp:74:10: error: ‘deque’ in namespace ‘std’ does not name a template type
74 | std::deque<std::unique_ptr<WorkItem>> queue;
| ^~~~~
httpserver.cpp:33:1: note: ‘std::deque’ is defined in header ‘<deque>’; did you forget to ‘#include <deque>’?
32 | #include <support/events.h>
+++ |+#include <deque>
33 |
httpserver.cpp: In member function ‘bool WorkQueue<WorkItem>::Enqueue(WorkItem*)’:
httpserver.cpp:92:13: error: ‘queue’ was not declared in this scope; did you mean ‘Enqueue’?
92 | if (queue.size() >= maxDepth) {
| ^~~~~
| Enqueue
httpserver.cpp:95:9: error: ‘queue’ was not declared in this scope; did you mean ‘Enqueue’?
95 | queue.emplace_back(std::unique_ptr<WorkItem>(item));
| ^~~~~
| Enqueue
httpserver.cpp: In member function ‘void WorkQueue<WorkItem>::Run()’:
httpserver.cpp:106:35: error: ‘queue’ was not declared in this scope; did you mean ‘Enqueue’?
106 | while (running && queue.empty())
| ^~~~~
| Enqueue
httpserver.cpp:110:31: error: ‘queue’ was not declared in this scope; did you mean ‘Enqueue’?
110 | i = std::move(queue.front());
| ^~~~~
| Enqueue
make[2]: *** [Makefile:6520: libbitcoin_server_a-httpserver.o] Error 1
make[2]: Leaving directory '/home/muhammad/Programs/SimorghCoin/src'
make[1]: *** [Makefile:10888: all-recursive] Error 1
make[1]: Leaving directory '/home/muhammad/Programs/SimorghCoin/src'
make: *** [Makefile:774: all-recursive] Error 1
and this is my configuration:
Options used to compile and link:
with wallet = yes
with gui / qt = no
with zmq = yes
with test = yes
with bench = yes
with upnp = auto
use asm = yes
sanitizers =
debug enabled = no
gprof enabled = no
werror = no
target os = linux
build os =
My OS is Manjaro 20.0.3 Lysia and i use gcc (GCC) 10.1.0.
Can anyone help me?
The include for deque is missing in /home/muhammad/Programs/SimorghCoin/src/httpserver.cpp. You can add a line
#include <deque>
after line 32.

C++: Enum: Error: Identifier expected instead of "}"

Building jdk8u from openjdk in solaris 11 x86 platform. Getting Warning: Identifier expected instead of "}" error in Enum. Usually this type of error will be thrown when we have comma at end of the enum. But in this case, there is no extra comma also. Can anyone point out what is the issue?
macro.hpp:
#ifndef INCLUDE_JFR
#define INCLUDE_JFR 1
#endif
#if INCLUDE_JFR
#define JFR_ONLY(code) code
#else
#define JFR_ONLY(code)
#endif
thread.hpp:
enum SuspendFlags {
// NOTE: avoid using the sign-bit as cc generates different test code
// when the sign-bit is used, and sometimes incorrectly - see CR 6398077
_external_suspend = 0x20000000U, // thread is asked to self suspend
_ext_suspended = 0x40000000U, // thread has self-suspended
_deopt_suspend = 0x10000000U, // thread needs to self suspend for deopt
_has_async_exception = 0x00000001U, // there is a pending async exception
_critical_native_unlock = 0x00000002U, // Must call back to unlock JNI critical lock
JFR_ONLY(_trace_flag = 0x00000004U) // call jfr tracing
};
Error:
Compiling /export/home/preethi/openjdk8u/hotspot/src/share/vm/compiler/abstractCompiler.cpp
Compiling /export/home/preethi/openjdk8u/hotspot/src/share/vm/utilities/accessFlags.cpp
Compiling ../generated/adfiles/ad_x86_32.cpp
"/export/home/preethi/openjdk8u/hotspot/src/share/vm/runtime/thread.hpp", line 202: Warning: Identifier expected instead of "}".
1 Warning(s) detected.
gmake[6]: *** [/export/home/preethi/openjdk8u/hotspot/make/solaris/makefiles/rules.make:148: accessFlags.o] Error 2
gmake[6]: *** Waiting for unfinished jobs....
"/export/home/preethi/openjdk8u/hotspot/src/share/vm/runtime/thread.hpp", line 202: Warning: Identifier expected instead of "}".
1 Warning(s) detected.
gmake[6]: *** [/export/home/preethi/openjdk8u/hotspot/make/solaris/makefiles/rules.make:148: abstractCompiler.o] Error 2
"/export/home/preethi/openjdk8u/hotspot/src/share/vm/runtime/thread.hpp", line 202: Warning: Identifier expected instead of "}".
1 Warning(s) detected.
gmake[6]: *** [/export/home/preethi/openjdk8u/hotspot/make/solaris/makefiles/rules.make:148: ad_x86_32.o] Error 2
gmake[5]: *** [/export/home/preethi/openjdk8u/hotspot/make/solaris/makefiles/top.make:112: the_vm] Error 2
gmake[4]: *** [/export/home/preethi/openjdk8u/hotspot/make/solaris/Makefile:226: product] Error 2
gmake[3]: *** [Makefile:231: generic_build2] Error 2
gmake[2]: *** [Makefile:177: product] Error 2
gmake[1]: *** [HotspotWrapper.gmk:45: /export/home/preethi/openjdk8u/build/solaris-x86-normal-server-release/hotspot/_hotspot.timestamp] Error 2
gmake: *** [/export/home/preethi/openjdk8u//make/Main.gmk:110: hotspot-only] Error 2
rules.make:
%.o: %.cpp
#echo Compiling $<
$(QUIETLY) $(REMOVE_TARGET)
$(QUIETLY) $(if $(findstring $#, $(NONPIC_OBJ_FILES)), \
$(subst $(VM_PICFLAG), ,$(COMPILE.CXX)) $(DEPFLAGS) -o $# $< $(COMPILE_DONE), \
$(COMPILE.CXX) $(DEPFLAGS) -o $# $< $(COMPILE_DONE))
Thanks in advance!
I think the idea of having an enum element conditional to a definition is not easy to mantain.
If you can't get rid of the Macro you can try this (thanks #Mestkon):
#define COMMA ,
enum SuspendFlags {
// NOTE: avoid using the sign-bit as cc generates different test code
// when the sign-bit is used, and sometimes incorrectly - see CR 6398077
_external_suspend = 0x20000000U, // thread is asked to self suspend
_ext_suspended = 0x40000000U, // thread has self-suspended
_deopt_suspend = 0x10000000U, // thread needs to self suspend for deopt
_has_async_exception = 0x00000001U, // there is a pending async exception
_critical_native_unlock = 0x00000002U // (Removed end comma) Must call back to unlock JNI critical lock
JFR_ONLY(COMMA _trace_flag = 0x00000004U) // call jfr tracing
};
Thanks. The problem i faced was when building jdk8u from openjdk.In configure, i given --enable-jfr=yes, resolved my issue.

Connecting OpenCV with netbeans 7.3.1

I'm trying to use OpenCV with Netbeans 7.3.1. I have tried following the various tutorials and blogs but cannot run any of the files. The following code was listed as good example code to check the opencv installation:
#include <cstdlib>
using namespace std;
#include "opencv.hpp"
#include "opencv_modules.hpp"
int main ( int argc, char **argv ) {
cvNamedWindow( "My Window", 1 );
IplImage *img = cvCreateImage( cvSize( 640, 480 ), IPL_DEPTH_8U, 1 );
CvFont font;
double hScale = 1.0;
double vScale = 1.0;
int lineWidth = 1;
cvInitFont( &font, CV_FONT_HERSHEY_SIMPLEX | CV_FONT_ITALIC, hScale, vScale, 0, lineWidth );
cvPutText( img, "Hello World!, I can now code openCV ", cvPoint( 0, 200 ), &font, Scalar
(255, 255, 0 ) );
cvPutText( img, "in a kickass IDE ", cvPoint( 150, 300 ), &font, cvScalar( 255, 255, 0 ) );
cvShowImage( "My Window", img );
cvWaitKey();
return 0;
}
The code results in the following error:
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory /cygdrive/c/Users/Daniel/Documents/NetBeansProjects/CppApplication_4'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin_1-Windows/cppapplication_4.exe
make[2]: Entering directory/cygdrive/c/Users/Daniel/Documents/NetBeansProjects/CppApplication_4'
mkdir -p build/Debug/Cygwin_1-Windows
rm -f build/Debug/Cygwin_1-Windows/main.o.d
g++ -c -g -I../../../../../Program\ Files/OpenCV/build/include/opencv2 -MMD -MP -MF build/Debug/Cygwin_1-Windows/main.o.d -o build/Debug/Cygwin_1-Windows/main.o main.cpp
In file included from main.cpp:11:
../../../../../Program Files/OpenCV/build/include/opencv2/opencv.hpp:46:33: opencv2/core/core_c.h: No such file or directory
../../../../../Program Files/OpenCV/build/include/opencv2/opencv.hpp:47:33: opencv2/core/core.hpp: No such file or directory
../../../../../Program Files/OpenCV/build/include/opencv2/opencv.hpp:48:39: opencv2/flann/miniflann.hpp: No such file or directory
../../../../../Program Files/OpenCV/build/include/opencv2/opencv.hpp:49:39: opencv2/imgproc/imgproc_c.h: No such file or directory
../../../../../Program Files/OpenCV/build/include/opencv2/opencv.hpp:50:39: opencv2/imgproc/imgproc.hpp: No such file or directory
../../../../../Program Files/OpenCV/build/include/opencv2/opencv.hpp:51:35: opencv2/photo/photo.hpp: No such file or directory
../../../../../Program Files/OpenCV/build/include/opencv2/opencv.hpp:52:35: opencv2/video/video.hpp: No such file or directory
../../../../../Program Files/OpenCV/build/include/opencv2/opencv.hpp:53:45: opencv2/features2d/features2d.hpp: No such file or directory
../../../../../Program Files/OpenCV/build/include/opencv2/opencv.hpp:54:43: opencv2/objdetect/objdetect.hpp: No such file or directory
../../../../../Program Files/OpenCV/build/include/opencv2/opencv.hpp:55:39: opencv2/calib3d/calib3d.hpp: No such file or directory
../../../../../Program Files/OpenCV/build/include/opencv2/opencv.hpp:56:29: opencv2/ml/ml.hpp: No such file or directory
../../../../../Program Files/OpenCV/build/include/opencv2/opencv.hpp:57:39: opencv2/highgui/highgui_c.h: No such file or directory
../../../../../Program Files/OpenCV/build/include/opencv2/opencv.hpp:58:39: opencv2/highgui/highgui.hpp: No such file or directory
../../../../../Program Files/OpenCV/build/include/opencv2/opencv.hpp:59:39: opencv2/contrib/contrib.hpp: No such file or directory
main.cpp: In function int main(int, char**)':
main.cpp:14: error:cvNamedWindow' undeclared (first use this function)
main.cpp:14: error: (Each undeclared identifier is reported only once for each function it appears in.)
main.cpp:15: error: IplImage' undeclared (first use this function)
main.cpp:15: error:img' undeclared (first use this function)
main.cpp:15: error: cvSize' undeclared (first use this function)
main.cpp:15: error:IPL_DEPTH_8U' undeclared (first use this function)
main.cpp:15: error: cvCreateImage' undeclared (first use this function)
main.cpp:16: error:CvFont' undeclared (first use this function)
main.cpp:16: error: expected ;' before "font"
main.cpp:17: error:font' undeclared (first use this function)
main.cpp:17: error: CV_FONT_HERSHEY_SIMPLEX' undeclared (first use this function)
main.cpp:17: error:CV_FONT_ITALIC' undeclared (first use this function)
main.cpp:17: error: cvInitFont' undeclared (first use this function)
main.cpp:18: error:cvPoint' undeclared (first use this function)
main.cpp:18: error: cvScalar' undeclared (first use this function)
main.cpp:18: error:cvPutText' undeclared (first use this function)
main.cpp:20: error: cvShowImage' undeclared (first use this function)
main.cpp:21: error:cvWaitKey' undeclared (first use this function)
nbproject/Makefile-Debug.mk:86: recipe for target build/Debug/Cygwin_1-Windows/main.o' failed
make[2]: *** [build/Debug/Cygwin_1-Windows/main.o] Error 1
make[2]: Leaving directory/cygdrive/c/Users/Daniel/Documents/NetBeansProjects/CppApplication_4'
nbproject/Makefile-Debug.mk:59: recipe for target .build-conf' failed
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory/cygdrive/c/Users/Daniel/Documents/NetBeansProjects/CppApplication_4'
nbproject/Makefile-impl.mk:39: recipe for target `.build-impl' failed
make: * [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 2s)
Could anyone help with providing a clear set of instructions or at least pointing to a concise guide?
Thanks,
Daniel
Assuming your include path contains C:\Program Files\OpenCV\include, and that the include files really are located there, replace
#include "opencv.hpp"
with
#include "opencv2/opencv.hpp"
You can probably do without #include "opencv_modules.hpp", otherwise it should be #include "opencv2/opencv_modules.hpp"

Can't run make using C++ stdlib system call

I've got the following code in C++
if (should_run_make) {
std::string make = "make -C ";
make.append(outdir);
std::cout << "Make cmd is " << make << std::endl;
system(make.c_str());
}
This reports the following:
Make cmd is make -C /home/hamiltont/temp/ make: Entering directory
/home/hamiltont/temp' make: *** No targets. Stop.
make: Leaving directory/home/hamiltont/temp'
However, doing it manually works fine in multiple ways e.g.
[hamiltont#4 generator]$ make -C /home/hamiltont/temp/
make: Entering directory `/home/hamiltont/temp'
g++ -O3 -I/usr/include/openmpi-x86_64 -L/usr/local/lib -L/usr/lib64/openmpi/lib -lmpi -lmpi_cxx -lboost_serialization -lboost_mpi stg_impl.cpp -o impl
make: Leaving directory `/home/hamiltont/temp'
[hamiltont#4 generator]$ cd /home/hamiltont/temp/
[hamiltont#4 temp]$ make
g++ -O3 -I/usr/include/openmpi-x86_64 -L/usr/local/lib -L/usr/lib64/openmpi/lib -lmpi -lmpi_cxx -lboost_serialization -lboost_mpi stg_impl.cpp -o impl
Are you generating the makefile from within your C program? That's the only reason I could imagine would cause that specific error message.
make: *** No targets. Stop.
Reproducing the error
Here's how I could generate that message:
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE *fp = fopen("Makefile", "w");
fputs("all:\n\techo Done.\n", fp);
system("make");
fclose(fp);
return 0;
}
This, predictably, prints:
make: *** No targets. Stop.
I say predictably because Makefile will be empty! This is because IO is buffered...
Fixed version
So, I close the file before calling system(), which flushes the buffer (fflush() would also do the trick):
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE *fp = fopen("Makefile", "w");
fputs("all:\n\techo Done.\n", fp);
fclose(fp);
system("make");
return 0;
}
Output:
echo Done.
Done.
I used C's IO functions for clarity, but the same rules apply to <iostream>.

FFmpeg libswresample linker error

I'm trying to set-up a function, using the ffmpeg c api, to re-sample a stream (AVStream format) to fixed (1channel - u8 sample) format.
I'm using ffmpeg libswresample library, but when I try to compile, I get a linker error that is strictly connected to swresample functions.
Let me post the code:
double *resample8(AVFrame *frame, int size, AVCodec* codec){
/* initialization of the output array */
double *out = new double[size];
/* create resampling context */
struct SwrContext *resampleContext;
resampleContext = swr_alloc();
if (!resampleContext) {
fprintf(stderr, "Could not allocate resampler context\n");
return NULL;
}
/* set options */
av_opt_set_int(resampleContext, "in_channel_layout", *(codec->channel_layouts), 0);
av_opt_set_sample_fmt(resampleContext, "in_sample_fmt", *(codec->sample_fmts), 0);
av_opt_set_int(resampleContext, "out_channel_layout", AV_CH_LAYOUT_MONO, 0);
av_opt_set_sample_fmt(resampleContext, "out_sample_fmt", AV_SAMPLE_FMT_U8, 0);
/* initialize the resampling context */
if (swr_init(resampleContext) < 0) {
fprintf(stderr, "Failed to initialize the resampling context\n");
return NULL;
}
return NULL;
}
Here is the inclusion:
#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavutil/avutil.h>
#include <libavutil/opt.h>
#include <libavutil/channel_layout.h>
#include <libavutil/samplefmt.h>
#include <libswresample/swresample.h>
#ifdef __cplusplus
} // end extern "C".
#endif // __cplusplus
And here is the error I get, compiling with netbeans, g++
(additional g++ commands: -lavcodec -lavformat -lavutil -lswresample -lfftw3 -lm)
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: ingresso nella directory "/home/davide/Documenti/Tesi/audiosync-fin/audiosync"
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/audiosync
make[2]: ingresso nella directory "/home/davide/Documenti/Tesi/audiosync-fin/audiosync"
mkdir -p build/Debug/GNU-Linux-x86
rm -f "build/Debug/GNU-Linux-x86/main.o.d"
g++ -c -g -MMD -MP -MF "build/Debug/GNU-Linux-x86/main.o.d" -o build/Debug/GNU-Linux-x86/main.o main.cpp
mkdir -p dist/Debug/GNU-Linux-x86
g++ -o dist/Debug/GNU-Linux-x86/audiosync build/Debug/GNU-Linux-x86/dataReader.o build/Debug/GNU-Linux-x86/main.o build/Debug/GNU-Linux-x86/tansforms.o build/Debug/GNU-Linux-x86/tognuplot.o -lavcodec -lavformat -lavutil -lswresample -lfftw3 -lm
build/Debug/GNU-Linux-x86/dataReader.o: nella funzione "resample8(AVFrame*, int, AVCodec*)":
/home/davide/Documenti/Tesi/audiosync-fin/audiosync/dataReader.cpp:285: riferimento non definito a "av_opt_set_sample_fmt"
/home/davide/Documenti/Tesi/audiosync-fin/audiosync/dataReader.cpp:288: riferimento non definito a "av_opt_set_sample_fmt"
/usr/local/lib/libswresample.so: riferimento non definito a "av_calloc#LIBAVUTIL_54"
collect2: error: ld returned 1 exit status
nbproject/Makefile-Debug.mk:65: set di istruzioni per l'obiettivo "dist/Debug/GNU-Linux-x86/audiosync" non riuscito
make[2]: *** [dist/Debug/GNU-Linux-x86/audiosync] Errore 1
make[2]: uscita dalla directory "/home/davide/Documenti/Tesi/audiosync-fin/audiosync"
nbproject/Makefile-Debug.mk:62: set di istruzioni per l'obiettivo ".build-conf" non riuscito
make[1]: *** [.build-conf] Errore 2
make[1]: uscita dalla directory "/home/davide/Documenti/Tesi/audiosync-fin/audiosync"
nbproject/Makefile-impl.mk:39: set di istruzioni per l'obiettivo ".build-impl" non riuscito
make: *** [.build-impl] Errore 2
BUILD FAILED (exit value 2, total time: 5s)
here is the linker configuration linker config
I searched for any clue about the linker error, and I found that it could be caused by multiple versions of ffmpeg installed. I removed ubuntu (I'm using 15.04) base installation of ffmpeg and installed ffmpeg 2.7.2 from the tar downloaded by ffmpeg.org
I can't seem to find a solution at the moment, can anyone help?
I think the linking order matters
refer this question
Why does the order in which libraries are linked sometimes cause errors in GCC?
Try this order
libavdevice libavformat libavfilter libavcodec libwscale libavutil libswresample libswscale libpostproc libavresample