How to build 32 bit and 64 bit library in Windows with 'cpp-library' plugin


(sameer kulkarni) #1

I am trying to use ‘cpp-library’ plugin to build application using Gradle 4.7. by default it tries to build 64 bit dlls. I want to build 32 bit dlls.
I am attaching build.gradle file used.

/*

import org.gradle.internal.os.OperatingSystem;

plugins {
id ‘cpp-library’
}

def libIncludePath = file(System.getenv(“ORACLE_HOME”)+’/oci/include’)
def libReleaseLinkLib = file(System.getenv(“ORACLE_HOME”)+’/oci/lib/msvc/oci.lib’)

library {
linkage = [Linkage.STATIC, Linkage.SHARED]

source.from "Source/ServiceLibs/OW"
privateHeaders.from "Source/include"
privateHeaders.from "Source/ServiceLibs"	

}

components.main.binaries.whenElementFinalized { binary ->
project.dependencies {
add(binary.includePathConfiguration.name, files(libIncludePath))
add(binary.linkLibraries.name, files(libReleaseLinkLib))

}

}

tasks.withType(CppCompile) {

macros.put ('OTL_ORA11G_R2','1')
macros.put ('WIN32','1')
macros.put ('_WIN32_WINNT','0x0400')
macros.put ('_USRDLL','1')
macros.put ('OTL_STL','1')
macros.put ('OTL_ORA_LEGACY_NUMERIC_TYPES','1')
macros.put ('_USRDLL','1')
macros.put ('DLL_EXPORT','1')	

compilerArgs.addAll toolChain.map { NativeToolChain toolChain ->
	List<String> compilerSpecificArgs = []
	if (toolChain instanceof VisualCpp) {			
		compilerSpecificArgs << '/MD'		
	}
	return compilerSpecificArgs
}

}

tasks.withType(LinkSharedLibrary) {
linkerArgs.addAll toolChain.map { NativeToolChain toolChain ->
List compilerSpecificArgs = []
if (toolChain instanceof VisualCpp) {
}
return compilerSpecificArgs
}
}


(Karl) #2

I’m using 4.10.1 and I still don’t see an option for adding a new platform like in the old cpp plugin:

model {
platforms {
    x86 {
        architecture "x86"
    }
}

Does anyone know if it’s possible using cpp-library or is this a coming soon feature?