"Invalid declaration of or reference to symbol ..." errors - fortran

I want to compile a makefile containing the following command on ubuntu 32 bit machine.
g77 -Wall -c -x f77-cpp-input -Wall
But I have some problems I cannot resolve.
[gustep.f][1] : In subroutine `gustep':
gustep.f:21:
INCLUDE 'gcblocks.inc'
^
Unable to open INCLUDE file `[gcblocks.inc][2]' at (^)
gustep.f:122:
CUTNEU = 1.0e-8
^
Invalid declaration of or reference to symbol `cutneu' at (^) [initially seen at (^)]
gustep.f:123:
IHADR = 5
^
Invalid declaration of or reference to symbol `ihadr' at (^) [initially seen at (^)]
gustep.f:125:
IF(NGKINE.GT.0) CALL GSKING(0)
^
Invalid declaration of or reference to symbol `ngkine' at (^) [initially seen at (^)]
gustep.f:129:
IF(GKIN(5,I).EQ.13) THEN
^
Invalid declaration of or reference to symbol `gkin' at (^) [initially seen at (^)]
gustep.f:140:
IF(INWVOL.EQ.1) THEN
^
Invalid declaration of or reference to symbol `inwvol' at (^) [initially seen at (^)]
gustep.f:141:
CALL GMEDIA(VECT,NUMED)
^
Invalid declaration of or reference to symbol `vect' at (^) [initially seen at (^)]
gustep.f:141:
CALL GMEDIA(VECT,NUMED)
^
Invalid declaration of or reference to symbol `numed' at (^) [initially seen at (^)]
gustep.f:144:
CALL UHTOC(NAMES(NLEVEL),4,NAME,4)
^
Invalid declaration of or reference to symbol `names' at (^) [initially seen at (^)]
gustep.f:144:
CALL UHTOC(NAMES(NLEVEL),4,NAME,4)
^
Invalid declaration of or reference to symbol `nlevel' at (^) [initially seen at (^)]
gustep.f:152:
IF(ITRA.EQ.TRAK_P) THEN
^
Invalid declaration of or reference to symbol `itra' at (^) [initially seen at (^)]
gustep.f:173:
COPY_NO = NUMBER(NLEVEL-2)
^
Invalid declaration of or reference to symbol `number' at (^) [initially seen at (^)]
gustep.f:177:
DE_P_DEL(M) = DE_P_DEL(M)+DESTEP*1000.
^
Invalid declaration of or reference to symbol `destep' at (^) [initially seen at (^)]
In file included from gustep.f:0:
Why this declaration is invalid? And how to solve the problem? May
someone explain it?

It's just what the compiler tells you:
Unable to open INCLUDE file `[gcblocks.inc][2]'
It can't find the file gcblocks.inc. The other errors are about missing variable declarations. Probably, these are declared in the missing file. Is gcblocks.inc in the current directory? If not, you will need to specify its directory with -I/path/to/include/dir/.

Related

Undefined symbol vs undefined reference

I saw this post here: ld: undefined symbol vs ld: undefined reference and I don't think it really talks about what the differences are between these 2 linker errors.
I usually get undefined reference linker errors when the linker can't find the definition of something (or I declared it and forgot to define it), but it seems undefined symbol serves the same purpose (the answer in the above linked post gives an example that seems to be aligned with when undefined reference arises, but maybe I'm missing some subtlety here?), so I'm a bit confused. Can someone clarify, perhaps with examples, of when each one arises during linking?
Edit: I didn't know the terminology for linker errors could be dependent on if using gnu, clang, etc...
In my case, I saw the undefined symbol error when using clang++ and the error was
stderr: ld.lld: error: undefined symbol: custom::linear::adapt()
Is undefined symbol the clang counterpart to gnu's undefined reference?

Unresolved external Vcl::Filectrl::SelectDirectory

I am using Vcl::Filectrl::SelectDirectory() in C++ Builder 10.3.1 but I receive error:
[ilink32 Error] Error: Unresolved external '__fastcall Vcl::Filectrl::SelectDirectory(System::UnicodeString, System::WideString, System::UnicodeString&, System::Set<Vcl::Filectrl::TSelectDirExtOpt, 0, 5>, Vcl::Controls::TWinControl *)' referenced from
What library should I link to resolve the error?
In C++ Builder 10.3.1, vclx.lib should be linked. Change the following line in the project file:
<AllPackageLibs>rtl.lib;vcl.lib;</AllPackageLibs>
to
<AllPackageLibs>rtl.lib;vcl.lib;vclx.lib</AllPackageLibs>
Add the following line to your C++ file:
#pragma link "vclx.lib"

Error: Undefined reference symbol to cv::VideoCapture::~VideoCapture(), DSO missing from command line

I am trying to run my opencv code on raspberry pi but i get the following error
/usr/bin/ld: CMakeFiles/main.dir/main.o: undefined reference to symbol 'cv::VideoCapture::~VideoCapture()'
/usr/local/lib/libopencv_videoio.so.3.0: error adding symbols: DSO missing from command line
DSO stands for "dynamic shared object" so it's probably a linking error. See this: openCV 2.4.7 error adding symbols: DSO missing from command line
Add -lopencv_features2d to your compile path.

Is CImg compatible with Emscripten

I have written a program in c++, but need to turn it to javascript to be run on an iPad. The only issue is that my program uses CImg. This is the compile command
em++ -std=c++11 -Wall -L./lib -lX11 -ljpeg -lpng -I./include -I./include/include main.cpp obj/object1.o obj/object2.o -o bin/executable.js
./include has my program header files and ./include/include has all the files that were located in /opt/X11/include which are needed to run CImg. and I get the following error:
warning: unresolved symbol: XUnlockDisplay
warning: unresolved symbol: XMoveWindow
warning: unresolved symbol: png_read_info
warning: unresolved symbol: XWindowEvent
warning: unresolved symbol: XFreeColormap
warning: unresolved symbol: XAllocClassHint
warning: unresolved symbol: XCreatePixmapCursor
warning: unresolved symbol: png_set_sig_bytes
warning: unresolved symbol: XGetWindowAttributes
warning: unresolved symbol: pthread_testcancel
warning: unresolved symbol: XSync
warning: unresolved symbol: jpeg_start_decompress
warning: unresolved symbol: jpeg_CreateDecompress
warning: unresolved symbol: jpeg_stdio_src
warning: unresolved symbol: XQueryKeymap
warning: unresolved symbol: png_create_write_struct
warning: unresolved symbol: jpeg_destroy
warning: unresolved symbol: png_read_end
warning: unresolved symbol: XCreateImage
warning: unresolved symbol: png_write_image
warning: unresolved symbol: XSetWindowColormap
warning: unresolved symbol: pthread_cancel
warning: unresolved symbol: XGrabKeyboard
warning: unresolved symbol: png_read_image
warning: unresolved symbol: XSetWMProtocols
warning: unresolved symbol: png_write_end
warning: unresolved symbol: png_set_gray_to_rgb
warning: unresolved symbol: XCheckTypedEvent
warning: unresolved symbol: png_init_io
warning: unresolved symbol: XFree
warning: unresolved symbol: png_set_filler
warning: unresolved symbol: XUnmapWindow
warning: unresolved symbol: png_set_longjmp_fn
warning: unresolved symbol: XCreateSimpleWindow
warning: unresolved symbol: XMapRaised
warning: unresolved symbol: XCloseDisplay
warning: unresolved symbol: XLockDisplay
warning: unresolved symbol: png_create_info_struct
warning: unresolved symbol: png_set_IHDR
warning: unresolved symbol: jpeg_write_scanlines
warning: unresolved symbol: XSelectInput
warning: unresolved symbol: jpeg_finish_compress
warning: unresolved symbol: XPutImage
warning: unresolved symbol: XCheckWindowEvent
warning: unresolved symbol: XUndefineCursor
warning: unresolved symbol: XVisualIDFromVisual
warning: unresolved symbol: jpeg_set_quality
warning: unresolved symbol: jpeg_CreateCompress
warning: unresolved symbol: XFreePixmap
warning: unresolved symbol: XCreateBitmapFromData
warning: unresolved symbol: pthread_create
warning: unresolved symbol: XStoreColors
warning: unresolved symbol: XInitThreads
warning: unresolved symbol: XLookupString
warning: unresolved symbol: png_get_valid
warning: unresolved symbol: jpeg_read_header
warning: unresolved symbol: jpeg_stdio_dest
warning: unresolved symbol: XSetInputFocus
warning: unresolved symbol: jpeg_std_error
warning: unresolved symbol: jpeg_destroy_decompress
warning: unresolved symbol: png_set_palette_to_rgb
warning: unresolved symbol: png_create_read_struct
warning: unresolved symbol: pthread_setcanceltype
warning: unresolved symbol: png_read_update_info
warning: unresolved symbol: jpeg_set_defaults
warning: unresolved symbol: png_set_expand_gray_1_2_4_to_8
warning: unresolved symbol: jpeg_read_scanlines
warning: unresolved symbol: jpeg_start_compress
warning: unresolved symbol: png_destroy_read_struct
warning: unresolved symbol: XResizeWindow
warning: unresolved symbol: png_get_IHDR
warning: unresolved symbol: jpeg_destroy_compress
warning: unresolved symbol: XCheckMaskEvent
warning: unresolved symbol: XCreateColormap
warning: unresolved symbol: XGetVisualInfo
warning: unresolved symbol: pthread_setcancelstate
warning: unresolved symbol: XDestroyWindow
warning: unresolved symbol: png_write_info
warning: unresolved symbol: XDefineCursor
warning: unresolved symbol: XUngrabKeyboard
warning: unresolved symbol: XSetClassHint
warning: unresolved symbol: png_set_tRNS_to_alpha
warning: unresolved symbol: jpeg_finish_decompress
warning: unresolved symbol: png_sig_cmp
warning: unresolved symbol: png_destroy_write_struct
warning: unresolved symbol: _ZTVSt9exception
I'm pretty sure it has something to do with linking the libraries. But I don't know if it is even possible to work with CImg while converting through Emscripten.
Any portable C or C++ codebase should work. But you do need to port all dependencies. Looks like the app uses Xlib and libpng, based on those warnings. You might need to port the X stuff to something emscripten already supports, like SDL. For png, there are a few ports around (or you can compile it yourself), e.g. https://github.com/hachque-Emscripten/libpng-1.2.49
If you don't need the X11 features of CImg (basically, if you don't want to display an image into a CImgDisplay window), then you can disable it by defining the macro cimg_display=0 while compiling your CImg-based code.

How to use decimal floating point in Gnu C++ (g++)?

GCC 4.5 added support for decimal floating points in the runtime library (http://gcc.gnu.org/gcc-4.5/changes.html). I'm able to compile code including , using namespace std::decimal, then using decimal64 and so on in the code.
Unfortunately, I'm missing some library for linking the code. I've not been able to find out which libraries should be required. DFP support is enabled in gcc (--enable-decimal-float=dpd)
Additionally, should there be some fast way of providing decimal literals in the code? By fast, I mean user defined literals that are handled by templates and translated at compile time. I do not want to provide doubles that are converted at runtime (despite performance and the fact that I really can't stand moving evaluations from compile time to runtime there are still rounding issues...). I've already found the suffix "df" but that does not seem to be recognized by the compiler.
I'm using gcc version 4.7.1 on target powerpc-ibm-aix7.1.0.0.
Linker error messages:
ld: 0711-317 ERROR: Undefined symbol: .__dpd_floatsisd
ld: 0711-317 ERROR: Undefined symbol: .__dpd_floatsidd
ld: 0711-317 ERROR: Undefined symbol: .__dpd_floatsitd
ld: 0711-317 ERROR: Undefined symbol: .__dpd_mulsd3
ld: 0711-317 ERROR: Undefined symbol: .__dpd_muldd3
ld: 0711-317 ERROR: Undefined symbol: .__dpd_multd3
ld: 0711-317 ERROR: Undefined symbol: .__dpd_floatdisd
ld: 0711-317 ERROR: Undefined symbol: .__dpd_floatunsdisd
ld: 0711-317 ERROR: Undefined symbol: .__dpd_floatdidd
ld: 0711-317 ERROR: Undefined symbol: .__dpd_floatunsdidd
ld: 0711-317 ERROR: Undefined symbol: .__dpd_floatditd
ld: 0711-317 ERROR: Undefined symbol: .__dpd_floatunsditd
TIA.
I've recently compiled gcc4.7.1 from source and had trouble with missing symbol __floatunsidf. This turned out to be a symbol required by libstdc++.so and defined in libgcc_s.so. Given that both Libraries are provided by gcc they should be compatible. In my case i still had a linker include to an old version of libgcc_s that i'd lifted from my target platform. Its probably worth doing
# to find out where libstdc++.so is:
gcc -print-file-name=libstdc++.so
# see if it references the symbol you're missing
readelf -a "path to libstdc++.so" | grep "symbol name"
and then doing the same for libgcc_s to see if they both define the symbol you are missing. Nb one will mark the symbol as undefined - thats how the linker knows its required.