LDC2 -I option results in unresolved externals - visual-c++

I'm using the latest LDC2 beta, and when running the compiler with -I (Look for imports also in ) it fails with unresolved externals. These are my commands.
$ ldc2 "source\setup.d" -I "source" -J "build\vars" -of "build\bin\setup.exe" -m32 -g
setup.obj : error LNK2019: unresolved external symbol __D6common17createErrorDialogFxC9ExceptionZv referenced in function __Dmain
setup.obj : error LNK2019: unresolved external symbol __D6common14getConsoleArgsFxPuZAAya referenced in function __D5setup20getAvailableBrowsersFZ14__foreachbody1MFKC3std7windows8registry3KeyZi
setup.obj : error LNK2001: unresolved external symbol __D6common12__ModuleInfoZ
build\bin\setup.exe : fatal error LNK1120: 3 unresolved externals
Error: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.15.26726\bin\HostX86\x86\link.exe failed with status: 1120
But this next one works fine when I explicitly tell the compiler that setup.d depends on common.d.
$ ldc2 "source\setup.d" "source\common.d" -J "build\vars" -of "build\bin\setup.exe" -m32 -g
I'm using LDC2 version 1.12.0-beta2, on DMD v2.082.0, on Windows with VS Build Tools 2017.
Any solutions or corrections appreciated.
Note: These compiler commands will be generated by other code, so using explicit filenames isn't feasible.

-I tells it where to find source code to import. The assumption is that the actual object code will be found in a pre-compiled library (or separate .obj files) somewhere that you pass to the linker.
If you want it to include the files in the build, using one of the newest ldc builds (as of the last couple months), it also has -i in addition to -I you can pass. -I tells it where to find the import files. -i tells it to add them to the build, instead of just treating them as an external library header.
So that's your three options:
compile the library separately, and add the resulting lib file to the link step
pass the source files all together on the command line (if it is generated by other code, just change that code to walk the directory lol)
get one of the latest compiler versions and add -i to the build command.

Related

Problem compiling exiv2 code in VS 2022: Undefined Reference/symbol error

I have some code in Linux that uses exiv2 to read the metadata of a folder full of photos, depending on requirements it can reconstruct missing metadata, and stamp a logo as well as lat/long onto the photos. I'm trying to port it into windows visual studio so that I can make a GUI and let other people use it.
I downloaded the MSVS source code for exiv2, I've added the include folder and lib folders both in the include line and the linker line in the project properties dialogue. When I try to compile I get an undefined reference error whenever an EXIV2 object is called.
I'm guessing I have some sort of linking or library building issue. I built it on linux using g++ and had no problems. If I weren't trying to make a GUI I'd probably just get a windows version of g++ to compile with.
This is one of the error messages I'm getting.
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: class std::_List_iterator<class std::_List_val<struct std::_List_simple_types > > __thiscall Exiv2::ExifData::begin(void)" (_imp?begin#ExifData#Exiv2##QAE?AV?$_List_iterator#V?$_List_val#U?$_List_simple_types#VExifdatum#Exiv2###std###std###std##XZ) referenced in function "int __cdecl uptake(class std::vector<struct EANphoto,class std::allocator > &,char *,char *)" (?uptake##YAHAAV?$vector#UEANphoto##V?$allocator#UEANphoto###std###std##PAD1#Z) CAPconsole C:\Users\ [redacted] \source\repos\CAPconsole\CAPconsole.obj 1
I've tried adding include files for both the "include" and the "lib" folders to both the include line and to the linker. I also tried to compile the sample program that came with Exiv2, and I get the same error,so I'm guessing it's a VS setting issue.
So, the way to do this is as follow:
In "Properties" … "C/C++" … "General" … "Additional Include Directories", add the include and lib folders, and do the same in
"Linker" … "Additional Library Directories".
Finally, in "Linker" … "Command Line" … "Additional Options", write in "exiv2.lib".

Setting up Rocket-chip for Questasim and getting error while compiling jtag_vpi.c

I have downloaded Rocket-chip from GIT, installed RISC-V tools and Generated the verilog files for Rocket core. Now I want to run the assembly tests that are given but I dont have VCS instead I have Questasim. I modified the Makefile to use Questasim but the two C++ files that needs to be compiled SimDTM.cc and jtag_vpi.c are giving error.
In Questa we cant compile C files along with verilog files instead we need to compile this separately and generate *.so file and link with -pli while simulating.
Here when I'm compiling jtag_vpi.c I'm getting and error saying invalid conversion from 'void*' to 'PLI_INT32. I'm compiling it with the below command and the error I'm getting is also pasted below.
g++ jtag_vpi.c -I $RISCV/include -I $MTI_HOME/questasim/include -std=c++11 -W -shared -Bsymblic -fPIC
.
.
riscv/rocket-chip/csrc/jtag_vpi.c:398:2: error: invalid conversion from ‘void*’ to ‘PLI_INT32 (*)(t_cb_data*) {aka int (*)(t_cb_data*)}’ [-fpermissive]
Line 398:2 is just an end of a function and the error is shown at the end of each such function.
Any help will be useful.
Thanks in advance.

Swift in Linux: use of unresolved identifier 'dispatch_async'

I compiled libdispatch.
This code is working:
import Dispatch
var lockQueue = dispatch_queue_create("com.test.async", nil);
But if I put this code to end file:
dispatch_async(lockQueue) {
print("test1");
}
I got an error:
use of unresolved identifier 'dispatch_async'
As I commented above, this appears to be a current limitation with the Swift Package Manager. It doesn't currently support the addition of the appropriate compile-time options, such as the ones needed to support blocks as inputs to GCD functions (-Xcc -fblocks).
In the meantime, you can avoid the Swift Package Manager and compile your files directly using swiftc, with the appropriate options. An example is provided by sheffler in their test repository:
swiftc -v -o gcd4 Sources/main.swift -I .build/debug -j8 -Onone -g -Xcc -fblocks -Xcc -F-module-map=Packages/CDispatch-1.0.0/module.modulemap -I Packages/CDispatch-1.0.0 -I /usr/local/include
The -I options will pull in your module maps for libdispatch, so adjust those to match where you've actually placed these system module directories.

perl compiler or packer that tolerate perl fork in windows plateform

If Perl code use fork or its variant like Paralell::Loops or Parallel::ForkManager, pp from Par::Packer generated standalone exe will crash when run, see example in https://groups.google.com/forum/?fromgroups#!topic/perl.par/U4HbbbcRRTQ. B::C or B::CC are also tested not working in such cases: activeperl can't even install it,show error like:
C.obj : error LNK2001: unresolved external symbol Perl_Iwatchaddr_ptr
C.obj : error LNK2001: unresolved external symbol Perl_Iwatchok_ptr
cygwin perl can install and generate exe as instructed in https://github.com/rurban/perl-compiler, but when we run it, it crashes with error like END failed--call queue abortedCouldn't print to pipe. Are there some tested working Perl compiler or packer that would work for fork?
Enclose all the code inside END {}, and change the use to require, like require Parallel::Loops. For those implicity dependance module, explicitly include them in pp, for example:
pp -M Params::Validate::XS -M Params::Validate::PP -M Class/Load/XS.pm -M Class/Load/PP.pm -o some-code.exe some-code.pl
If the script do not need to share data between the parent and the children, we can also use MCE, which have a use threads option that is compatible with pp and we do not need the END {} method.

SFML linker problems on eclipse VC++

I am trying to use the SFML library for audio in my project.
I am developing in eclipse juno for c++ and am using SFML v1.6.
I added sfml-audio-d.lib, sfml-main-d.lib, and sfml-system-d.lib into
C/C++ General > paths and symbols>libraries
I also defined a macro named SFML_DYNAMIC into
C/C++ Build>Settings>C++ Compiler>Preprocessor 'Defines /D' section
I added the directory that contains all the dlls into the PATH environment variable.
In my code I make use of sf::SoundBuffer, but when I try to build the project I get the following linker error:
Chunk.obj : error LNK2001: unresolved external symbol "private: static class sf::SoundBuffer * Chunk::breakBlockSound" (?breakBlockSound#Chunk##0PAVSoundBuffer#sf##A)
MyProject.exe : fatal error LNK1120: 1 unresolved externals
Had to rebuild the project in VS2010 before using it. Works now.

Resources