How to fix meson generating an incorrect linker flag (--subsystem console) - clang

I've created a simple project to get myself accustomed to meson, but the build keeps failing.
This is what I did (to set up the environment, and to build):
set CC=clang
set CC_LD=lld
set CFLAGS="--target x86_64-pc-windows-msvc"
meson build
cd build
ninja
My meson.build is as follows:
project('EtaClient', 'c')
src = ['src/main.c', 'src/linkedlist.c']
executable('EtaClient', src)
target = 'x86_64-pc-windows-msvc'
While building, I get the following errors (the obj files are built successfully, but they're not linked and thus the exe isn't built):
LINK : warning LNK4044: unrecognized option '/-subsystem'; ignored
LINK : fatal error LNK1181: cannot open input file 'console.obj'
clang: error: linker command failed with exit code 1181 (use -v to see invocation)
When I look in my build.ninja to see what's going on, I find:
build EtaClient.exe | EtaClient.pdb: c_LINKER EtaClient.exe.p/src_main.c.obj EtaClient.exe.p/src_linkedlist.c.obj
LINK_ARGS = "-Wl,/nologo" "-Wl,/release" "-Wl,/nologo" "-Wl,/DEBUG" "-Wl,/PDB:EtaClient.pdb" "-Wl,--subsystem,console" "-lkernel32" "-luser32" "-lgdi32" "-lwinspool" "-lshell32" "-lole32" "-loleaut32" "-luuid" "-lcomdlg32" "-ladvapi32"
I replace "-Wl,--subsystem,console" with "-Wl,/subsystem:console", and the build compiles successfully, but I have to manually make this edit each time I modify my meson.build.
Could someone tell me why this happens, and how to set up meson to generate the correct flag?
Thanks in advance.

use clang-cl instead of clang and leave out the defintion of the linker when you are on windows
set CC=clang-cl
set CFLAGS="--target x86_64-pc-windows-msvc"
meson build
cd build
ninja
see
https://github.com/mesonbuild/meson/issues/4232

Related

Gluon Mobile GraalVM iOS 14.1

Since I’ve updated Xcode to version 12.2 because of update iOS to 14.1 I’m not able to build my Gluon Mobile project. An error occurs at the end of the build process by linking. I saw that the object files. They are created but not linked.
Object file folder :
.../target/client/arm64-ios/gvm/tmp/SVM-1605296582688/llvm
I’ve tried to link only and got following errors in .../GraalVMGluonSample/target/client/log :
Process
=======
link
Command Line
============
clang /Users/kojojo/NetBeansProjects/GraalVMGluonSample/target/client/arm64-ios/gvm/Hello Gluon/AppDelegate.o /Users/kojojo/NetBeansProjects/GraalVMGluonSample/target/client/arm64-ios/gvm/tmp/SVM-1605296582688/com.GraalVMgluonsample.GraalVMgluonsample.o /Users/kojojo/NetBeansProjects/GraalVMGluonSample/target/client/arm64-ios/gvm/tmp/SVM-1605296582688/llvm/llvm.o -ljava -lnio -lzip -lnet -lprefs -ljvm -lfdlibm -lz -ldl -lj2pkcs11 -lsunec -ljaas -lextnet -lstdc++ -w -fPIC -arch arm64 -mios-version-min=11.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.1.sdk -Wl,-force_load,/Users/kojojo/.gluon/substrate/javafxStaticSdk/15-ea+gvm22/ios-arm64/sdk/lib/libprism_es2.a -Wl,-force_load,/Users/kojojo/.gluon/substrate/javafxStaticSdk/15-ea+gvm22/ios-arm64/sdk/lib/libglass.a -Wl,-force_load,/Users/kojojo/.gluon/substrate/javafxStaticSdk/15-ea+gvm22/ios-arm64/sdk/lib/libjavafx_font.a -Wl,-force_load,/Users/kojojo/.gluon/substrate/javafxStaticSdk/15-ea+gvm22/ios-arm64/sdk/lib/libprism_common.a -Wl,-force_load,/Users/kojojo/.gluon/substrate/javafxStaticSdk/15-ea+gvm22/ios-arm64/sdk/lib/libjavafx_iio.a -lpthread -llibchelper -lffi -ldarwin -Wl,-framework,Foundation -Wl,-framework,UIKit -Wl,-framework,CoreGraphics -Wl,-framework,MobileCoreServices -Wl,-framework,OpenGLES -Wl,-framework,CoreText -Wl,-framework,QuartzCore -Wl,-framework,ImageIO -Wl,-framework,CoreBluetooth -Wl,-framework,CoreImage -Wl,-framework,CoreLocation -Wl,-framework,CoreMedia -Wl,-framework,CoreMotion -Wl,-framework,CoreVideo -Wl,-framework,Accelerate -Wl,-framework,AVFoundation -Wl,-framework,AudioToolbox -Wl,-framework,MediaPlayer -Wl,-framework,UserNotifications -Wl,-framework,ARKit -Wl,-framework,AVKit -Wl,-framework,SceneKit -Wl,-framework,StoreKit -o /Users/kojojo/NetBeansProjects/GraalVMGluonSample/target/client/arm64-ios/Hello Gluon.app/Hello Gluon -L/Users/kojojo/.gluon/substrate/javafxStaticSdk/15-ea+gvm22/ios-arm64/sdk/lib -L/opt/graalvm/lib/svm/clibraries/ios-arm64 -L/Users/kojojo/.gluon/substrate/javaStaticSdk/11-ea+1/ios-arm64/labs-staticjdk/lib/static -L/Users/kojojo/NetBeansProjects/GraalVMGluonSample/target/client/arm64-ios/gvm/lib -Wl,-force_load,/Users/kojojo/NetBeansProjects/GraalVMGluonSample/target/client/arm64-ios/gvm/lib/libLifecycle.a -Wl,-force_load,/Users/kojojo/NetBeansProjects/GraalVMGluonSample/target/client/arm64-ios/gvm/lib/libStatusbar.a -Wl,-force_load,/Users/kojojo/NetBeansProjects/GraalVMGluonSample/target/client/arm64-ios/gvm/lib/libDisplay.a -Wl,-force_load,/Users/kojojo/NetBeansProjects/GraalVMGluonSample/target/client/arm64-ios/gvm/lib/libUtil.a -Wl,-force_load,/Users/kojojo/NetBeansProjects/GraalVMGluonSample/target/client/arm64-ios/gvm/lib/libStorage.a
Output
======
ld: building for iOS, but linking in object file built for macOS, file '/Users/kojojo/NetBeansProjects/GraalVMGluonSample/target/client/arm64-ios/gvm/tmp/SVM-1605296582688/llvm/llvm.o'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Result
======
result: 1
I upgraded the plugin <client.plugin.version>0.1.34</client.plugin.version> and then I folowed the instruction in the error message. I installed graalvm-ce-java11-20.2.0.hotfix-xcode12.zip and changed GRAALVM_HOME but anyway I get error during build :
Process
=======
compile
Command Line
============
/Library/Java/JavaVirtualMachines/graalvm-ce-java11-20.2.0.hotfix-xcode12/bin/native-image -Djdk.internal.lambda.eagerlyInitialize=false --no-server -H:+ExitAfterRe$
Output
======
env: bash: No such file or directory
Result
======
result: 127
I noticed that the structure of the graalvm-ce-java11-20.2.0.hotfix-xcode12.zip is different than a regular relaese 20.2.0. It doesn‘t contain /Contents/Home folders. Can it cause an issue?
There is a solution based on the hints from José Pereda:
Upgrade Gluon Client Plugin in pom.xml <client.plugin.version>0.1.34</client.plugin.version>
Build your project. You will get a message with the instruction to upgrade GraalVM. Download graalvm-ce-java11-20.2.0.hotfix-xcode12.zip (Link is in the message)
Unpack the zip file move to /Library/Java/JavaVirtualMachines/graalvm-ce-java11-20.2.0.hotfix-xcode12
Set environment variable GRAALVM_HOME=/Library/Java/JavaVirtualMachines/graalvm-ce-java11-20.2.0.hotfix-xcode12
Check if environment variable PATH contains at least 
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

No such file or directory when generate framework

When I make a new framework with aggregate to generate universal framework , but a error present , as follow :
cp: build/Release-iphoneos/TEST.framework/: No such file or directory
fatal error: lipo: can't open input file: build/Release-iphoneos/TEST.framework/TEST (No such file or directory)
Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure
And here is a screenshot of the error:
This is a new target , I only want to test generate framework , but fail!
As the error message said, no TEST.framework can be found in the path <PROJECT_DIR>/build/Release-iphoneos/TEST.framework.
You need to check the script you use, or the blog post which you reference is out-date.
First you should build the target specified in xcodebuild command directly to see if it can build succeed.
Check what the actual build path is. If the path(build/) is not exist, you can try to specified the build path for xcodebuild, OBJROOT=${WRK_DIR} SYMROOT=${WRK_DIR}

build alljoyn_darwin in Xcode 6.1.1 and get a No SConstruct file found error

Recently I am doing some AllJoyn development on iOS and OS X. When I run xcodebuild for alljoyn_darwin.xcodeproj using command line as below:
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project alljoyn_darwin.xcodeproj -scheme alljoyn_core_ios -sdk iphoneos -configuration Debug PLATFORM_NAME=iphoneos
I got an error like this:
export variant=normal
/opt/local/bin/scons -u OS=darwin CPU=arm BR=on BINDINGS=cpp SERVICES= WS=off VARIANT=Debug --
scons: *** No SConstruct file found.
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/scons-2.3.4/SCons/Script/Main.py", line 920, in _main
Command /opt/local/bin/scons failed with exit code 2
** BUILD FAILED **
The following build commands failed:
ExternalBuildToolExecution alljoyn_core_ios
(1 failure)
I really have no idea why I got this, I followed all the instruction in the official site--Build From Source and I am sure I set the correct OPENSSL_ROOT path. I installed scons using Macport and it was installed correctly. I tried double-click the alljoyn_darwin.xcodeproj from finder but I got the same error.
scons: *** No SConstruct file found.
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/scons-2.3.4/SCons/Script/Main.py", line 920, in _main
Command /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/scons-2.3.4 failed with exit code 2
So I am stuck here. But the thing is I can successfully run AllChatz sample in sdk_14.12 for iOS in iphonesimulator for iPhone6. openssl version is 1.0.2 and I tried build both for alljoyn sdks 14.06 and 14.12. same error happened. I don't know if this is related. Anyone can help here? Many thanks.
The problem is that scons cant find the root-level SConstruct script, which probably doesnt help much as you can see that in the error :)
When you use the "-u", that tells scons to look up the directory structure for the root-level SConstruct script.
SCons must be executed from within the project directory structure. Look for the root-level SConstruct, and make sure you're executing scons from within the project directory structure.

compile vlc for android

I am trying to compile vlc for android in RHEL 6.4 (Santiago). I am following the instructions given in this page https://wiki.videolan.org/AndroidCompile. I am getting some errors.
First is when I build this, I get error in git.
error: unknown switch `B'. refer http://txt.do/6tjh for log
I changed the git checkout -B android ${TESTED_HASH} to git checkout -b android ${TESTED_HASH}. Then this error does not come
Then when I run sh compile.sh, I get following errors (refer http://tny.cz/bb552912 I have removed some part of log which had code to download packages like automake, protobuf, ragel etc)
rmdir: failed to remove /root/Documents/android/android/vlc/contrib/arm-linux-androideabi/include/freetype2/freetype/config': No such file or directory
make[1]: [install] Error 1 (ignored)
rmdir: failed to remove `/root/Documents/android/android/vlc/contrib/arm-linux-androideabi/include/freetype2/freetype': No such file or directory
make[1]: [install] Error 1 (ignored)
Then if I again run sh compile.sh, weird things happen. I don't get this error again, but it builds some library and then stops.
First it build libdvdcss and then stops (refer http://tny.cz/5f3ab58f)
It ends like
Libraries have been installed in:
/root/Documents/android/android/vlc/contrib/arm-linux-androideabi/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following:
add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution
add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
use the `-Wl,-rpath -Wl,LIBDIR' linker flag
have your system administrator add LIBDIR to `/etc/ld.so.conf'
make[2]: Leaving directory `/root/Documents/android/android/vlc/contrib/contrib-android-arm-linux-androideabi/dvdcss'
make[1]: Leaving directory `/root/Documents/android/android/vlc/contrib/contrib-android-arm-linux-androideabi/dvdcss'
touch .dvdcss
Then each time I run "sh compile.sh" it build one more library and then stops.
it has build following libraries
libopenjpeg (http://tny.cz/86236e8b)
libgpg-error http://tny.cz/26c5626b)
ffmpeg (http://tny.cz/1f05aa0f)
gmp
libgcrypt
iconv
nettle
libjpeg
Finally I get an following error and I am not able to do any after that (http://tny.cz/ed7798ea)
autopoint: * The AM_GNU_GETTEXT_VERSION declaration in your configure.ac file requires the infrastructure from gettext-0.18 but this version is older. Please upgrade to gettext-0.18 or newer.
autopoint: * Stop.
autoreconf: autopoint failed with exit status: 1
configure.in:20: error: possibly undefined macro: AM_PROG_LIBTOOL
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
autoreconf: /root/Documents/android/android/vlc/extras/tools/build/bin/autoconf failed with exit status: 1
make: *[.ogg] Error 1
I am not able to find gettext package with version > .18 for RHEL 6.4. Maximum available is .17 which is installed
Is not this weird. Should not doing "sh compile.sh" build all libraries and I should not have to do this again and again.
Also Is RHEL 6.4 (Santiago) compatible for building vlc android
Any help for these errors

Library not found for -llib. (clang: error: linker command failed with exit code 1 (use -v to see invocation))

I am working on a project that was previously done and uploaded on app store.When I run this app in Xcode 5.0 it is working fine but when I run this on Xcode Version 5.1.1 (5B1008) I am getting Linker error on both device and simulator.
Error Message- Library not found for -llib. (clang: error: linker command failed with exit code 1 (use -v to see invocation)).
I have searched a lot but I didn't get any thread about Library not found for -llib error. Is there anything I have to change in build settings to resolve this?
Look at the linker command line in detail for the -L options being used:
Then use Terminal or Finder to see if your libXXX.a file exists in those directories. If the library exists elsewhere then you need to configure your Library Search Paths:
However there several details which you have not provided in your question when using a library within an app:
Is the library built as part of the Xcode project/workspace (as in the first image)?
Is the library supplied by a third-party with binary (.a) and header files (as in the second image)?
TL;DR: I ran make in the wrong directory so the paths were messed up.
Problem:
>make
linking ../build/release/yubikey-personalization-gui
/usr/x86_64-suse-linux/bin/ld: cannot find -llib
...
I ran into this when compiling the Yubikey Personalisation Tool. I tracked down the -llib call in my Makefile which looked like this:
...
LINK = #echo linking $# && g++
...
LIBS = $(SUBLIBS) -L/usr/lib64 -L../lib/release -llib -lyubikey -lykpers-1 -lQtGui -L/usr/lib64 -L/usr/X11R6/lib -lQtCore -lpthread
...
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
So it was setting a variable called LINK which would print "linking" and then call g++, which is the compiler.
Then it set the var LIBS which would hold the ominous -llib.
Then it composes and runs the command $(LINK) ... $(LIBS).
Which runs g++ with the parameter -llib.
And what does that do? Turns out -l<something> is telling the compiler to use the something-library. So it asks for the library called lib here. Which is strangely generic. I figured out that the sources came with a directory called lib/, which was at ../lib.
So starting make from a directory higher up fixed it.
You should remove libstdc++ from other linker flags in your xcode project
https://stackoverflow.com/a/53103383/1344237

Resources