LINK : fatal error LNK1104: cannot open file 'Lib\lua.lib' - dll

CMakeLists.txt:
project(lua)
aux_source_directory(${LUA_SRC_DIR} LUA_SOURCES)
list(REMOVE_ITEM LUA_SOURCES ${LUA_SRC_DIR}/lua.c ${LUA_SRC_DIR}/luac.c)
add_definitions(-DBUILD_LUA_AS_DLL -DLUA_LIB)
add_library(lua SHARED ${LUA_SOURCES})
seems nothing wrong, why this happen?

Related

Postsharp throws System.Runtime.InteropServices.COMException (0x8013141C): Strong name key container not found. (Exception from HRESULT: 0x8013141C)

Adding the question for anyone in the future that needs to resolve the same problem
Environment: Visual Studio 2017 or 2019
Build error from Postsharp signing the assembly
MSBuild postsharptest.csproj /T:Rebuild /P:PostSharpTrace=StrongName /V:D /P:PostSharpHost=Native > postsharp.log
C:\ProgramData\PostSharp\4.0.41\bin.Release\postsharp.4.0-x86.exe obj\Debug\Before-PostSharp\PostsharpTest.exe /X:default /NoLogo /P:Output=C:\PostsharpTest\obj\Debug\PostsharpTest.exe /P:ReferenceDirectory=C:\PostsharpTest /P:Configuration=Debug /P:Platform=AnyCPU "/P:SearchPath=bin\Debug\|obj\Debug\|C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\|C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Facades\ " /P:IntermediateDirectory=obj\Debug\PostSharp /P:CleanIntermediate=False /P:MSBuildProjectFullPath=C:\PostsharpTest\postsharptest.csproj /P:SignAssembly=true /P:PrivateKeyLocation=Thycotic.snk /P:PrivateKeyContainer= /P:DelaySign= "/P:ResolvedReferences=C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Microsoft.CSharp.dll|C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll|C:\PostsharpTest\packages\PostSharp.4.0.41\lib\net35-client\PostSharp.dll|C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll|C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.DataSetExtensions.dll|C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.dll|C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll|C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.dll|C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.dll|C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.Linq.dll" /P:SymbolFile=bin\Debug\PostsharpTest.pssym /P:WriteWeavingSymbols=True /P:ConstraintVerificationEnabled=True /P:RuntimeVerificationEnabled=True /P:TargetFrameworkVersion=v4.5 /P:TargetFrameworkIdentifier=.NETFramework /P:TargetFrameworkProfile= "/P:TargetFrameworkMoniker=.NETFramework,v4.5" "/P:NativeFrameworkMoniker=.NETFramework,v4.5.1" /P:BindingMapsDirectory=C:\ProgramData\PostSharp\4.0.41\BindingMaps /P:PostSharpLibraryProfile= /P:AspectProviders= "/P:Language=C#" /T:StrongName /config C:\ProgramData\PostSharp\4.0.41\bin.Release\postsharp.4.0-x86.exe.config
C:\PostsharpTest\postsharptest.csproj : warning PS0131: The project 'ModuleDeclaration PostsharpTest.exe' does not contain any aspect or other transformation. You can disable PostSharp for this project by editing the project properties in Visual Studio. Remember to enable PostSharp back if you add an aspect to this project.
C:\PostsharpTest\postsharptest.csproj : error PS0099: Unhandled exception (4.0.41.0, 32 bit, CLR 4.5, Release): System.Runtime.InteropServices.COMException (0x8013141C): Strong name key container not found. (Exception from HRESULT: 0x8013141C)
C:\PostsharpTest\postsharptest.csproj : error PS0099: at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
C:\PostsharpTest\postsharptest.csproj : error PS0099: at ^nIsIyZ7TTJqY.GetKeyInfo(^8gP93Xsl\+Imn _0)
C:\PostsharpTest\postsharptest.csproj : error PS0099: at ^Up6wxUIUnN6a.^3w8852HL()
C:\PostsharpTest\postsharptest.csproj : error PS0099: at ^Up6wxUIUnN6a.^VfvrABjR()
C:\PostsharpTest\postsharptest.csproj : error PS0099: at ^Up6wxUIUnN6a.^SkiT()
C:\PostsharpTest\postsharptest.csproj : error PS0099: at ^Up6wxUIUnN6a.^8KD6D2SV(String _0)
C:\PostsharpTest\postsharptest.csproj : error PS0099: at ^cyC/TYSlPGB/.^wvPm(^RtksFin57NJ8 _0, ^8gP93Xsl\+Imn _1)
C:\PostsharpTest\postsharptest.csproj : error PS0099: at PostSharp.Sdk.Extensibility.Tasks.CompileTask.Execute()
C:\PostsharpTest\postsharptest.csproj : error PS0099: at PostSharp.Sdk.Extensibility.Project.ExecutePhase(String phase)
C:\PostsharpTest\postsharptest.csproj : error PS0099: at PostSharp.Sdk.Extensibility.Project.Execute()
C:\PostsharpTest\postsharptest.csproj : error PS0099: at PostSharp.Hosting.PostSharpObject.ExecuteProjects()
C:\PostsharpTest\postsharptest.csproj : error PS0099: at PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation).
Properties | Signing | Sign the assembly
I was able to resolve the problem when attempting to create a new signing key with Microsoft's Strong Name Tool (SN.exe), I was getting an access denied error.
sn -k jeff.snk
Failed to generate a strong name key pair -- Access is denied.
Using Process Monitor showed me the problem was access denied to a specific file in C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys. After giving myself permission to all files in the directory I was able to create the signing key and run the msbuild without any errors.

MSBuild: 'error MSB6006: "cmd.exe" exited with code 1.'

When attempting to build TensorFlow with CMake and MSBuild on Windows 10, I get the following error when running MSBuild:
"C:\work\tensorflow\tensorflow\contrib\cmake\build\tf_tutorials_example_trainer.vcxproj" (default target) (1) ->
"C:\work\tensorflow\tensorflow\contrib\cmake\build\tf_core_gpu_kernels.vcxproj" (default target) (90) ->
(CustomBuild target) ->
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171,5): error MSB6006: "cmd.exe" exited with code 1. [C:\work\tensorflow\tensorflow\contrib\cmake\build\tf_core_gpu_kernels.vcxproj]
351 Warning(s)
1 Error(s)
So I only get one error message, and that just tells me that cmd.exe was closed with an error code indicating that there was a problem, but not what the problem was. So how can I find out what caused this problem so I can solve it?
This error commonly happens because the default cmake install location requires admin privileges (normally C:/Program Files/).
There are two simple ways around this:
Run visual studio as Administrator
Override the CMAKE_INSTALL_PREFIX variable to point somewhere not requiring admin privileges
Personally, I'd recommend the second option (When configuring cmake, the command would be something like: cmake . -DCMAKE_INSTALL_PREFIX=D:/Some/Path)

How to use GMP library in case of nested makefiles in c++

I have a source code of a tool written in c++. The tool is compose of several modules that compiles perfectly using a set of nested makefiles. I wanted to add a certain feature to a specific module in that tool that requires using the gmplib library. However, it gives me this error:
### Module sdf - sdf3cost
Creating executable sdf3cost-sdf
/sdf3/build/work/Linux/lib/libsdf3-sdf.so: undefined reference to `__gmpz_clear'
/sdf3/build/work/Linux/lib/libsdf3-sdf.so: undefined reference to `__gmpz_init_set_ui'
collect2: error: ld returned 1 exit status
make[3]: *** [sdf3cost-sdf] Error 1
make[2]: *** [sdf3cost] Error 2
make[1]: *** [tools] Error 2
make: *** [sdf] Error 2
I think that I know the reason behind that error is related to the usage of -lgmp flag. However, I don't know where to add it in the makefiles since they are nested. Or maybe it is a different problem, I don't know. Can any body help me please?

Build Linux Kernel module with warning i2c_register_board_info undefined

I follow an example in kernel.org to write an i2c driver but unfortunately when i compile i got this warning
WARNING: "i2c_register_board_info" [/home/pi/builddriver/samplei2c/pn535.ko] undefined!
Although compile with 1 warning and no error, I cannot insmod module. this is error when insmod
insmod: ERROR: could not insert module pn535.ko: Invalid module format
My question is how to solve the warning above?, I think it make .ko file to be invalid. Here is my source code on
pastebin
thank for your help!
That is not possible in a kernel module simply because the function i2c_register_board_info is not exported from the kernel source tree to the kernel modules (built using obj-m targets). You can achieve this by building your driver within the kernel source tree using (obj-y targets).

FXCop assembly load failure

Command line:
"C:\Program Files (x86)\Microsoft Fxcop 10.0\FxCopCmd.exe" /file:XXX.exe /out:fxcop-report.xml /outxsl:none /forceoutput /searchgac /assemblyCompareMode:StrongNameIgnoringVersion /verbose
Error from report:
<Type>Microsoft.FxCop.Common.AssemblyLoadException</Type>
<ExceptionMessage>Could not load XXX.</ExceptionMessage>
<InnerType>Microsoft.FxCop.Sdk.InvalidMetadataException</InnerType>
<InnerExceptionMessage>The following error was encountered while reading module 'XXX': Security attribute type does not have a default constructor: System.Security.Permissions.SecurityPermission.</InnerExceptionMessage>
Anyone any ideas?