compiling v8 on windows - c++

When I am trying to compile like this
cl /Iinclude hello_world.cpp v8.lib
I get this error
LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
and when I am trying to do it like this
cl /Iinclude v8.lib Winmm.lib WSock32.lib hello_world.cpp ws2_32.lib
I am getting this error
LINK : fatal error LNK1181: cannot open input file 'Winmm.lib'
how to fix this?

The compiler/linker can't find the Windows lib files. There are lots of ways to resolve this. For example, you can add the paths to the locations of the lib files to the LIB environment variable. Or you can pass the /LIBPATH option to the linker.
Finally, it doesn't look like you are compiling V8 here. It would appear that you are just trying to link to the V8 library that has already been compiled.

Related

Building a DLL with both assembly and C++ functions

I need to create a single DLL containing both C++ and MASM functions.
I compile C++ files with g++ which outputs .o files.
Is it possible to use these with MASM linker? If not, how can I link these?
Edit:
I tried converting .o file to .obj using objconv utility and then linking it with assembly object files but it didn't work.
Here are the commands I used:
g++ -mabi=ms -c copy.cpp
objconv -fcoff64 copy.o copy.obj
C:\masm32\bin\ml /c /Zd /coff init.asm series.asm windows.asm
C:\masm32\bin\link /DLL /SUBSYSTEM:WINDOWS /DEF:mydll.def /LIBPATH:c:\masm32\lib init.obj series.obj windows.obj copy.obj
And the output is:
copy.obj : fatal error LNK1136: invalid or corrupt file
What am I doing wrong?

Error message while compiling a program

I’m a newbie to C++ and Linux. There is this code I’m playing with that requires me to install the HElib (Homomorphic encryption library and other libraries - GMP, NTL) which I did. I want to compile the code (main.cpp) that has a header file (FHE.h) in HElib. My problem is how can I link FHE.h (in HElib folder) and main.cpp (in another folder) together so that I can compile them. I have tried some commands
g++ -I/Home/HElib/src/FHE.h main.cpp -o main
Error message
main.cpp:1:17: fatal error: FHE.h: No such file or directory
compilation terminated.
Another command line
g++ -I/Home/HElib/Src/FHE.h -I/Home/SimpleFHESum-master/SimpleFHESum-master/main.cpp -o main]
Error Message
g++: fatal error: no input files
compilation terminated.
What's wrong and how can I fix this?
The -I flag adds the following directory to the include path of the compiler. This enables you to write e.g. #include "FHE.h" even though that file is not located in the same folder as the source file you're trying to compile.
Have you tried just removing the 'FHE.h' part from your -I directive?
g++ -I/Home/HElib/src ...

Compiling FFmpeg with Libass using MSVC

First a bit of background.
I'm trying to compile ffmpeg on windows with the libass extensions/configuration option.
Using the visual studio project libass-msvc I built libass using Visual Studio as a static lib.
I then installed MinGW with MSYS and pkg-config. Following the instructions on the ffmpeg MSVC installation guide I configured the environment to build with the MSVC linker and to build in x64.
When I try to configure libass for compilation using ./configure --enable-libass --toolchain=msvc I get the following error in the log file:
File not found ass/ass.h
pkg-config can not find libass
I have tried the following to fix this.
Create a .pc file for libass and add this to the PKG_CONFIG_PATH environment variable. See file content below. (After doing this pkg-config libass --version prints 0.81, not the right version number but at least something.)
Copy libass .h files into a MinGW/include/ass folder and the .lib file into the MinGW/libs folder.
Add libass include and bin folders to PATH environment variable
Download libass and dependencies source then try to build it using MSYS with MSVC compiler. My aim here was to be able to use "make install" and let MinGW install libass to the correct locations. After hours of trying to fix linker errors, I abandoned this idea as some of the libass dependencies make files only work with the GCC GNU compiler.
Compile libass with GCC GNU using MinGW make/make install then try and install libass using the GNU libs. Again this led to linker errors (I know this was a bad idea but was worth a try).
Tried using extra lib and include build configuration options --extra-cflags="ffmpeg-dir/extra/include" \
--extra-ldflags="ffmped-dir/extra/ffmpeg_build/lib" then adding the libs and .h files into those locations
.pc file
libass.pc:
prefix=/MinGW
includedir=libass-directory/include
libdir=libass-director/x64/bin/
Name: libass
Description: Libass project
Version: 0.13.7
I am now completely stuck and out of ideas if anyone could give any insight or suggestions into what I'm doing wrong that would be fantastic.
Update
I created INCLUDE and LIBDIR environment path variable containing the libass paths. Which now correctly includes libass. However, I now get the following linker error for the function check_ass_library_init.
check_func_headers ass/ass.h ass_library_init
check_ld cc
check_cc
BEGIN ./ffconf.RZMYFWdc/test.c
1 #include
2 #include
3 long check_ass_library_init(void) { return (long)
ass_library_init; }
4 int main(void) { int ret = 0;
5 ret |= ((intptr_t)check_ass_library_init) & 0xFFFF;
6 return ret; }
END ./ffconf.RZMYFWdc/test.c
cl -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -
D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -
D_WIN32_WINNT=0x0502 -nologo -c -Fo./ffconf.RZMYFWdc/test.o
./ffconf.RZMYFWdc/test.c
test.c
./ffconf.RZMYFWdc/test.c(3): warning C4311: 'type cast': pointer truncation
from 'ASS_Library *(__cdecl *)(void)' to 'long'
./compat/windows/mslink -nologo -out:./ffconf.RZMYFWdc/test.exe
./ffconf.RZMYFWdc/test.o psapi.lib advapi32.lib shell32.lib ole32.lib
test.o : error LNK2019: unresolved external symbol ass_library_init
referenced in function check_ass_library_init
./ffconf.RZMYFWdc/test.exe : fatal error LNK1120: 1 unresolved externals
ERROR: libass not found using pkg-config
The libass test project which uses ass_library_init compiles fine using the same lib files, the libs appear to be fine.
From what I see from this line "./compat/windows/mslink -nologo -out:./ffconf.RZMYFWdc/test.exe ./ffconf.RZMYFWdc/test.o psapi.lib advapi32.lib shell32.lib ole32.lib" libass is not being passed to the linker.
I suspect that the configuration file is not creating the link to libass in the make file when compiling with MSVC.
Am I correct or am I going about compiling this in the wrong way?

codeblocks error ld||cannot find -lSDL2_image| ld||cannot find -lSDL2_mixer|

i am using code-blocks mingw32 portable as my c++ compiler
my compiler gives error while compiling the cpp(link to cpp is given below).
error is as follows :-
ld||cannot find -lSDL2_image|
ld||cannot find -lSDL2_mixer|
||=== Build finished: 2 errors, 0 warnings (0 minutes, 4 seconds) ===|
i had already included -lSDL2_image -lSDL2_mixer in the linker options
link to cpp file downloaded from lazyfoo :-
http://lazyfoo.net/tutorials/SDL/06_extension_libraries_and_loading_other_image_formats/index2.php
I would really appreciate your help!!!!
you just need to add the lib files of
sdl_image and sdl_mixer
to the minw32's lib folder as in above error compiler isn't able to find linked libraries

LINK1104 cannot open boost static library using visual studio 2008 command prompt

I'm trying to compile a cpp file which uses static boost libraries. I'm using the visual studio 2008 command prompt as I have not set up a VS project file.
The command I'm using is (run from the folder containing my source code):
cl /EHsc /I "C:\Program Files\boost\boost_1_53_0" Client.cpp
The error is:
LINK: fatal error LNK1104: cannot open file 'libboost_system-vc90-mt-s-1_53.lib'
However, the file 'libboost_system-vc90-mt-s-1_53.lib' can be found in "C:\Program Files\boost\boost_1_53_0\stage\lib" so my understanding is that I've installed boost properly and I'm just failing to link to it?
I've tried including it directly using
cl /EHsc /I"C:\Program Files\boost\boost_1_53_0" /I "C:\Program Files\boost\boost_1_53_0\stage\lib\" Client.cpp
which gives the same error.
I've also tried linking to it directly using /link as follows:
cl /EHsc /I"C:\Program Files\boost\boost_1_53_0" /link "C:\Program Files\boost\boost_1_53_0\stage\lib\libboost_system-vc90-mt-s-1_53.lib" Client.cpp
Which returns a different error:
cl : Command line error D8003 : missing source filename
I seem to be calling the compiler flags wrong? But I can't see where/how.
There is a similar question here,but the solution involves issues with how visual studio/ the project file is set up. Since I don't have a project file, is there an easy solution for the above that I can't see or would I need to set up a project?
Thanks for any help in advance!
The linker needs to be told where the library file is located. You were very close with the last command line, but the file name needs to precede the /link option. This should work:
cl /EHsc /I"C:\Program Files\boost\boost_1_53_0" Client.cpp /link "C:\Program Files\boost\boost_1_53_0\stage\lib\libboost_system-vc90-mt-s-1_53.lib"
Also, when linking to multiple libraries in the same directory, it is more concise to use the LIBPATH option to tell the linker where to look for .lib files.
cl /EHsc /I"C:\Program Files\boost\boost_1_53_0" Client.cpp /link "libboost_system-vc90-mt-s-1_53.lib" /LIBPATH:"C:\Program Files\boost\boost_1_53_0\stage\lib\"